Pagini recente » Cod sursa (job #1144716) | Cod sursa (job #2113921) | Monitorul de evaluare | Cod sursa (job #866615) | Cod sursa (job #44231)
Cod sursa(job #44231)
{
Problema fractii
Versiunea n.00
}
Program fractii;
Type vector = array[1..1000000] of Longint;
Var nr, boom : int64;
c, c2, t : vector;
n, i, j, aux, k : longint;
Function totient( m : longint ) : Longint;
Var i, rez : Longint;
Begin
rez := m;
i := 1;
While ( i<=k ) and (c2[i] <= m) do
Begin
if m mod c2[i] = 0 then
Begin
rez := rez div c2[i];
rez := rez*(c2[i]-1);
End;
i := i+1;
End;
totient := rez;
End;
Begin
Assign( input, 'fractii.in' );
Reset( input );
Readln( n );
Close( input );
k := 0;
For i := 2 to n do
Begin
If c[i] = 0 then
Begin
k := k+1;
c2[k] := i;
aux := i;
j := aux;
While j <= n do
Begin
j := j+aux;
c[j] := 1;
End;
End;
t[i] := totient( i );
End;
nr := 1;
For i := 2 to n do
Begin
boom := t[i] shl 1;
nr := nr + boom;
End;
Assign( output, 'fractii.out' );
Rewrite( output );
Writeln( nr );
Close( output );
End.