Cod sursa(job #208478)
Utilizator | Data | 16 septembrie 2008 18:53:29 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include<fstream.h>
#include<math.h>
ifstream fin("d:\\borlandc\\work\\ciur.in");
ofstream fout("d:\\borlandc\\work\\ciur.out");
unsigned long n, i, j, c;
int sw;
int main()
{
fin >> n;
for( i = 2; i <= n; i++ )
{
sw = 1;
for( j = 2; j <=sqrt(i); j++ )
if( i % j == 0 )
{
sw = 0;
break;
}
if(sw) { c++; cout << i << ' ';}
}
fout << c;
return 0;
}