Cod sursa(job #1189225)

Utilizator MarianMMorosac George Marian MarianM Data 21 mai 2014 21:04:49
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.31 kb
#include <stdio.h>

int n, nrp;	bool P[2000001];

int main(){
	int i;

	freopen("ciur.in", "r", stdin);
	freopen("ciur.out", "w", stdout);

	scanf("%d", &n);
	for (i = 2; i <= n; i++) for (j = 2 * i; j <= n; j += i) P[j] = 1;
	for (i = 2; i <= n; i++) if (!P[i]) nrp++;
	printf("%d", nrp);

	return 0;
}