Cod sursa(job #280734)

Utilizator sicazoRLazar Marius sicazoR Data 13 martie 2009 15:42:07
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.34 kb
#include<fstream>
#include<math.h>
using namespace std;
int main (){
	int i,j,ok,ct;
	unsigned long int n;
	ifstream f("ciur.in");
	ofstream g("ciur.out");
	f>>n;
	ct=0;
	for(i=2;i<=n;i++){
		ok=1;
		for(j=2;j<=sqrt(1.0*i);j++){
			if(i%j==0)
				ok=0;
		}
		if(ok==1)
			ct++;
	}
	g<<ct;
	f.close();
	g.close();
	return 0;
}