1
0
Fork 0
Project-Euler/C/10-c.c
2012-04-05 05:32:56 -04:00

29 lines
No EOL
366 B
C
Executable file

#include <stdio.h>
#define LENGTH 1000
void main() {
long long sum = 0;
int numbers[LENGTH + 1] = {0};
int i = 1, j;
while(i < LENGTH) {
if(numbers[i] == 1) {
continue;
}
for(j = 1; i * j < LENGTH; j++) {
numbers[i * j] = 0;
}
i++;
}
for(i = 1; i < LENGTH; i++) {
if(numbers[i] == 0) {
sum += i;
}
}
printf("SUM: %lld", sum);
}