Pagini recente » Cod sursa (job #2336392) | Monitorul de evaluare | Cod sursa (job #1358828) | Cod sursa (job #328839) | Cod sursa (job #2480019)
#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;
}