static void RMTisPrimeNumber(Args _args)
{
int x;
int i;
int startTime;
int endTIme;
NoYes isPrime = NoYes::Yes;
startTime = timeNow();
// x = 324161901; // Composite
// x = 179426549; // Prime
// x = 15487469; // Prime
// x = 1301081; // Prime
if (x mod 2)
{
// Odd number
for ( i = 3 ; i < x DIV 2; i+=2)
{
if (!(x mod i))
{
info(strFmt('%1 is divisible by %2.It is a composite number.',x,i));
isPrime = NoYes::No;
endTime = timeNow();
break;
}
}
}
else if( x != 1 && x != 0)
{
info(strFmt('%1 is divisible by 2.It is a composite number.',x));
isPrime = NoYes::No;
}
else
{
info(strFmt('By defination %1 is nor prime nor composite.',x));
isPrime = NoYes::No;
}
if(isPrime == NoYes::Yes)
info(strFmt('%1 is a prime number',x));
endTime = timeNow();
if((endTIme - startTime) == 1)
info(strFmt('The process took %1 second of my time to complete.',endTIme - startTime));
else if ((endTIme - startTime) > 1 )
info(strFmt('The process took %1 seconds of my time to complete.',endTIme - startTime));
else
info('It took almost nothing of my time to process.');
}
{
int x;
int i;
int startTime;
int endTIme;
NoYes isPrime = NoYes::Yes;
startTime = timeNow();
// x = 324161901; // Composite
// x = 179426549; // Prime
// x = 15487469; // Prime
// x = 1301081; // Prime
if (x mod 2)
{
// Odd number
for ( i = 3 ; i < x DIV 2; i+=2)
{
if (!(x mod i))
{
info(strFmt('%1 is divisible by %2.It is a composite number.',x,i));
isPrime = NoYes::No;
endTime = timeNow();
break;
}
}
}
else if( x != 1 && x != 0)
{
info(strFmt('%1 is divisible by 2.It is a composite number.',x));
isPrime = NoYes::No;
}
else
{
info(strFmt('By defination %1 is nor prime nor composite.',x));
isPrime = NoYes::No;
}
if(isPrime == NoYes::Yes)
info(strFmt('%1 is a prime number',x));
endTime = timeNow();
if((endTIme - startTime) == 1)
info(strFmt('The process took %1 second of my time to complete.',endTIme - startTime));
else if ((endTIme - startTime) > 1 )
info(strFmt('The process took %1 seconds of my time to complete.',endTIme - startTime));
else
info('It took almost nothing of my time to process.');
}