Cod sursa(job #2342599)
| Utilizator | Data | 12 februarie 2019 22:46:18 | |
|---|---|---|---|
| Problema | Fractii | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <fstream>
#include <queue>
#include <vector>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
int f(int n)
{
int i = 1, rez = n;
while(n > 1)
{
i++;
if(n % i == 0)
{
rez *= (i - 1);
rez /= i;
}
while(n % i == 0)
{
n /= i;
}
}
return rez;
}
long long nr(int n)
{
if(n == 1) return 1;
return nr(n - 1) + 2 * f(n);
}
int main()
{
fin >> n;
fout << nr(n);
return 0;
}
