Cod sursa(job #872547)

Utilizator RomanDanRoman Dan Traian RomanDan Data 6 februarie 2013 11:00:32
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.25 kb
#include<iostream.h>
#include<fstream.h>
int main()
{
	ifstream f("ciur.in");
	ofstream g("ciur.out");
	int n,i,s=0,nr=0,d;
	f>>n;
	for(i=1;i<n;i++)
	{
		nr=0;
		for(d=1;d<=i;d++)
			if(i%d==0)
				nr++;
		if(nr==2)
			s++;
	}
	g<<s;
}