Pagini recente » Cod sursa (job #1713554) | Cod sursa (job #1225232) | Cod sursa (job #1518849) | Cod sursa (job #3172379) | Cod sursa (job #738741)
Cod sursa(job #738741)
function cmmdc(x,y:longint):longint;
var t,j:longint;
begin
if x>y then begin t:=x;x:=y;y:=t;end;
for j:=x downto 1 do if (x mod j=0)and(y mod j=0) then begin cmmdc:=j;break;end;
end;
var f,g:text;s,n,x,i,y:longint;
begin
assign(f,'sum.in');reset(f);assign(g,'sum.out');rewrite(g);read(f,n);
for i:=1 to n do begin read(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.