Pagini recente » Cod sursa (job #1256732) | Cod sursa (job #28860) | Cod sursa (job #1090391) | Cod sursa (job #2356179) | Cod sursa (job #38750)
Cod sursa(job #38750)
#include <fstream.h>
#include <math.h>
int main(){
long long n,i,s2=0,s=1,ok,d,p,aux;
ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n;
for(i=2;i<=n;i++){
d=2;ok=0;s2=1;
while(d<=i/2&&!ok)
if(i%d==0)ok=1;
else d++;
if(ok){
d=2;aux=i;
while(aux>1){
p=0;ok=0;
while(aux%d==0){aux/=d;p++;ok=1;}
if(ok==1)s2*=(d-1)*pow(d,p-1);
d++;
}
s+=2*s2;
}else
s+=2*(i-1);
}
g<<s;
return 0;
}