Cod sursa(job #160448)

Utilizator nighthawkghenea alexandru madalin nighthawk Data 15 martie 2008 20:58:36
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.32 kb
#include<fstream.h>
#include<math.h>
int main()
{long i,n,j;
 int s=3,sw;
 ifstream f("ciur.in");
 ofstream g("ciur.out");
 f>>n;
 for(i=9;i<=n;i=i+2)
       {sw=1;
       for(j=3;j<=sqrt(i);j=j+2)
		{if(i%j==0)
			{sw=0;
			 break;
			 }
		}
       if(sw)
		s++;
       }
 g<<s;
 g.close();
 return 0;}