Pagini recente » Cod sursa (job #1109376) | Cod sursa (job #2368332) | Cod sursa (job #2416832) | Cod sursa (job #1534694) | Cod sursa (job #147406)
Cod sursa(job #147406)
program sum;
var
f,g:text;
y,x,n,i,s:longint;
function cmmdc(x,y:longint):longint;
var
r:word;
begin
r:=x mod y;
while r<>0 do
begin
x:=y;
y:=r;
r:=x mod y;
end;
cmmdc:=y;
end;
begin
assign(f,'sum.in');
reset(f);
readln(f,n);
assign(g,'sum.out');
rewrite(g);
for i:=1 to n do
begin
readln(f,x);
s:=0;
for y:=1 to 2*x do
if cmmdc(x,y)=1 then
s:=s+y;
writeln(g,s);
end;
close(f);
close(g);
end.