Pagini recente » Cod sursa (job #2748844) | Cod sursa (job #291142) | Cod sursa (job #1853253) | Cod sursa (job #1395983) | Cod sursa (job #222280)
Cod sursa(job #222280)
const max=100000;
var n,x,i,j:longint;
v,a,b:array [1..100010] of longint;
p:array [1..100010] of int64;
begin
assign(input,'sum.in'); reset(input);
assign(output,'sum.out'); rewrite(output);
for i:=2 to trunc(sqrt(max)) do
if v[i]=0 then
for j:=1 to max div i do v[i*j]:=i;
for i:=2 to max do
if v[i]=0 then v[i]:=i;
for i:=2 to max do begin
x:=i;
while x mod v[i]=0 do x:=x div v[i];
b[i]:=x; a[i]:=i div x;
if b[i]=1 then p[i]:=i-(i div v[i])
else p[i]:=p[a[i]]*p[b[i]];
end;
readln(n);
for i:=1 to n do begin
readln(x);
writeln(2*p[x]*x);
end;
close(input); close(output);
end.