Cod sursa(job #2480021)
Utilizator | Data | 24 octombrie 2019 19:22:57 | |
---|---|---|---|
Problema | Fractii | Scor | 30 |
Compilator | cpp-32 | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <fstream>
#include <math.h>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
unsigned int n;
int fractie(int x){
if(x == 1)
return 1;
int aux = x, p = 1, power = 0, nr = 2;
while(aux != 1){
if(!(aux % nr)){
aux /= nr;
power++;
}
if(aux % nr){
if(power){
p = p * (nr - 1) * pow(nr, power - 1);
}
power = 0;
nr++;
}
}
return 2 * p + fractie(x - 1);
}
int main(){
in >> n;
out << fractie(n);
return 0;
}