Computer Science 23 Online
OpenStudy (anonymous):

Best C++ Program to generate prime numbers. Best C++ Program to generate prime numbers. @Computer Science

OpenStudy (anonymous):

For any given candidate number, the smallest possible divisor is 2, and the largest possible divisor is (candidate / 2). So, for that range of divisors, check the result of (candidate % [modulo] divisor). If any result is zero, then the candidate is not a prime. If none of the divisor yield a zero modulo result, the candidate is a prime. Leave it to you to do your own coding of this algorithm. It's really quite simple.

OpenStudy (anonymous):

im ganna write it in c language which might help ya: all i understanf is that you wanna generate all possible prime numbers (and lets say from 0 to 1000) int count; int i; for(count=0;count<=1000;count ++) { int p=0; for(i=0;i<=count;i++) if(count % i ==0) p++; if(p==2) printf("count\t); }

OpenStudy (anonymous):

hope it will work....try it :D

OpenStudy (anonymous):

I read a webpage that said the best-performing algorithm was the Sieve of Eratosthenes. But it requires O(n) space, where n is the max prime you're looking for. A simpler way is to check divisors from 2 to sqrt(n). To optimize it a little more only test odd n's (ignore 2). To optimize more, only test odd divisors. To optimize more, only test prime divisors. To only test prime divisors, keep a list of primes that you find, and iterate over it when testing divisors (stop when you get to sqrt(n)).

Latest Questions
YouMyPlug: Made some art to, took me 2 years to finish, ud83dudc4cud83dude29
24 seconds ago 3 Replies 0 Medals
Jaydennnn: I got 6 friends where dfck i find mo
13 hours ago 0 Replies 0 Medals
XShawtyX: Artud83cudfa8 (This shi took me like 1-2 hrsud83dude2d)
17 hours ago 4 Replies 3 Medals
prettystrawberry: Loookkk
1 day ago 4 Replies 0 Medals
Brotherlylove: Whoever got insta dm Mr it
1 day ago 0 Replies 0 Medals