Pagini recente » Cod sursa (job #2796324) | Cod sursa (job #1871288) | Cod sursa (job #2516036) | Cod sursa (job #2156535) | Cod sursa (job #599147)
Cod sursa(job #599147)
#include <iostream>
#include <fstream>
#define nmax 1000002
using namespace std;
unsigned long n, k=0;
unsigned long p[nmax];
void citire(){
ifstream in("fractii.in");
in >> n;
in.close();
}
void afis(){
for(unsigned long i=1;i<=n;++i) k+=p[i];
k*=2;
++k;
ofstream out("fractii.out");
out << k;
out.close();
}
void cerne(){
for (unsigned long i = 1; i <= n; ++i)
p[i] = i-1;
for (unsigned long i = 2; i <= n; ++i)
for (unsigned long j = 2*i; j <= n; j += i)
p[j] -= p[i];
}
int main()
{
citire();
cerne();
afis();
return 0;
}