Pagini recente » Cod sursa (job #2072539) | Cod sursa (job #844012) | Cod sursa (job #2358142) | Cod sursa (job #2542275) | Cod sursa (job #2033070)
#include <iostream>
#include <fstream>
using namespace std;
bool prop(int x)
{
int ok = 1;
if(x < 2 || x > 2 && x % 2 == 0)
ok = 0;
else
for(int d = 3; d * d <= x; d +=2)
if(x % d == 0)
ok = 0;
if(ok == 1)
return true;
return false;
}
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
int n, x, nr = 0;
f>>n;
for(int i = 2; i < n; i++)
if(prop(i) == true)
nr++;
g<<nr;
return 0;
}