Cod sursa(job #191191)

Utilizator O_NealS. Alex O_Neal Data 25 mai 2008 16:56:52
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include<fstream.h>

ifstream fin("fractii.in");
ofstream fout("fractii.out");


                
int main()
 {
          unsigned long n,i,j;
          unsigned int phi[10000001];
          fin>>n;
          
          for ( i = 1; i <= n; ++i)
              phi[i] = i-1;
          for ( i = 2; i <= n; ++i)
              for (j = 2*i; j <= n; j += i)
                phi[j] -= phi[i];
          j=0;
          for(i=1; i<=n; i++)
             j+=phi[i];
          fout<<j*2+1;     

 }