forked from IsaacTay/Infinite-Prime-Number-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
41 lines (39 loc) · 925 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
long Primes[10000000] = {2};
long num = 3;
long num2;
long i = 0;
long i2 = 1;
long e = 100000 ;
int main()
{
printf("1. 2\n");
while (i2 < e) {
while (i != -1) {
num2 = num % Primes[i];
if (i == 0) {
if (num2 == 0) {
i = -1;
}
else {
Primes[i2] = num;
i2 = i2 + 1;
i = -1;
printf("%ld. %ld\n", i2, num + 1);
}
}
else {
if (num2 == 0) {
i = -1;
}
else {
i = i - 1;
}
}
}
i = i2 - 1;
num = num + 1;
}
return 0;
}