Pagini recente » Cod sursa (job #2033938) | Cod sursa (job #434430) | Cod sursa (job #3162989) | Cod sursa (job #1789246) | Cod sursa (job #217580)
Cod sursa(job #217580)
#include<fstream.h>
double n;
double era(double n)
{
int i, j, nr = 1,p[500];
for (i = 1; ((i * i) << 1) + (i << 1) <= n; i += 1) {
if ((p[i >> 3] & (1 << (i & 7))) == 0) {
for (j = ((i * i) << 1) + (i << 1); (j << 1) + 1 <= n; j += (i << 1) + 1) {
p[j >> 3] |= (1 << (j & 7));
}
}
}
for (i = 1; 2 * i + 1 <= n; ++i)
if ((p[i >> 3] & (1 << (i & 7))) == 0)
nr++;
return nr;
}
int main()
{ ifstream f("fractii.in");
f>>n;
f.close();
ofstream g("fractii.out");
double omfg,i;
omfg=0;
for(i=era(n);i;i--)
omfg=omfg+i;
g<<n+omfg;
return 0;
}