at least he tried
The Weird and The Wonderful
42
Posts
25
Posters
261
Views
1
Watching
-
You are right, this is awful. Better is:
int Primes[]={2,3,5,7,...,113};
int size=sizeof(Primes[])/sizeof(Primes[0]);
int i=0;
while (i<size)
{
if (num==Primes[i]) return true;
}
return false;Last modified: 21hrs 3mins after originally posted --
Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]
MSVC++ generates an error on the above code.;) // why not having then: int Primes[]={2,3,5,7,...};:rolleyes:
-
wikipedia stops at 113 too :) http://en.wikipedia.org/wiki/Prime_number[^]
That would be one heck of a long list if they (the original coder or Wikipedia) attempted listing all the primes ;) Rob G