Cod sursa(job #519056)

Utilizator antohieantohie andrei antohie Data 3 ianuarie 2011 21:15:00
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.56 kb
#include<iostream>
#include<math.h>
#include<fstream>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int main (void)
{
       int test,n,i,aux,j,k;
       in>>n;
       k=0;
       for(i=1;i<=n;i++)
       {
              test=1;
              if(i<=1)
              test=0;
              else
              {
                     for(j=2;j<=sqrt(i);j++)
                     if(i%j==0)
                     test=0;
              }
              if (test==1)
              k++;
       }
       out<<k;
       return 0;
}