First of all, I am fairly new to C, and know nothing about C++, and only took the w3schools.org tutorial on C, and made a few practice programs. What I am looking for is something simple that can find all primes form 1 to 1000000 in under half an hour. I do not know how to implement anything complex like Sieve of Atkin or other complex algorithms. Can you either explain Sieve of Atkin either simpler (like in laymen's terms) or demonstrate it in C? Please keep in mind that I just took the beginner course in C from w3schools.
The code that I am using is as follows:
#include <stdio.h>
int n = 0, i, b, e, flag = 0;
int main() {
printf("Enter a positive integer that will be the higher bound: ");
scanf("%d", &b);
for (n = 0; n < b; n++) {
if (n == 0 || n == 1) {
flag = 1;
}
for (i = 2; i <= n / 2; ++i) {
if (n % i == 0) {
flag = 1;
}
}
if (flag == 0) {
printf("%d is a prime number.\n", n);
} else {
}
flag = 0;
}
return 0;
}