Cod sursa(job #422384)
Utilizator | Data | 22 martie 2010 16:47:03 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.21 kb |
#include<fstream.h>
int n,j,i,s,k=1;
int main()
{ifstream f("ciur.in");ofstream g("ciur.out");f>>n;
for(i=3;i<=n;i=i+2)
{s=0;j=3;
while(s==0 && j<i/2)
{if(i%j==0) s=1;j=j+2;}
if(s==0) k++;}
g<<k;
return 0;}