Pagini recente » Cod sursa (job #2847696) | Cod sursa (job #774053) | Cod sursa (job #2903324) | Cod sursa (job #995327) | Cod sursa (job #516870)
Cod sursa(job #516870)
// Sieve of Eratosthenes.cpp : Defines the entry point for the console application.
//
#include "stdio.h"
int a[2000001], N, c=0;
int main () {
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%d", &N);
for (int i = 2; i <= N; ++i) {
if (a[i]==0) {
++c;
for (int j = i+i; j < N; j+=i) {
a[j]=1;
}
}
}
printf("%d", c);
return 0;
}