Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void primegen(int count)
- {
- int ret[count];
- ret[0] = 2;
- int totalprimes = 1, next = ret[0], top, found, i;
- found = 0;
- while (totalprimes < count) {
- next++;
- top = next >> 1;
- top++;
- found = 0;
- while (!found) {
- found = 1;
- for (i = 2; i <= top; i++)
- if (next % i == 0) {
- found = 0;
- next++;
- }
- }
- ret[totalprimes] = next;
- totalprimes++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement