Cod sursa(job #624120)

Utilizator raazvvannheghedus razvan raazvvann Data 21 octombrie 2011 19:14:54
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.33 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
	ifstream f("ciur.in");
	ofstream g("ciur.out");	
	int n,j,i,x=0;
	bool ok;
	f>>n;
	for(i=3;i<=n;i=i+2)
	{
		
		ok=true;
		for(j=2;j<i-1;j++)
			if(i%j==0) ok=false;
		if(ok==true) x++;
	}
	x++;
	g<<x;
	f.close();
	g.close();
	return 0;
}