Cod sursa(job #222253)
| Utilizator | Data | 21 noiembrie 2008 15:08:48 | |
|---|---|---|---|
| Problema | Sum | Scor | 45 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
function cmmdc(a,b:longint):longint;
var r:longint;
begin
r:=a mod b;
while r<>0 do begin
a:=b; b:=r; r:=a mod b;
end;
cmmdc:=b;
end;
var n,x,i,j,s:longint;
begin
assign(input,'sum.in'); reset(input);
assign(output,'sum.out'); rewrite(output);
readln(n);
for i:=1 to n do begin
readln(x); s:=0;
for j:=1 to x*2 do
if cmmdc(x,j)=1 then s:=s+j;
writeln(s);
end;
close(input); close(output);
end.