Cod sursa(job #23112)

Utilizator asu_the_bestRusu Robert asu_the_best Data 28 februarie 2007 09:33:59
Problema Sum Scor 45
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.38 kb
var x,i,n,s,y,a,b:longint;
begin
 assign(input,'sum.in');reset(input);
 assign(output,'sum.out');rewrite(output);
 readln(n);
 for i:=1 to n do begin
  read(x);s:=0;
  for y:=1 to 2*x do begin
   a:=y;
   b:=x;
   while (a<>b) do
    if (a>b) then a:=a-b
             else b:=b-a;
   if (a=1)then s:=s+y;
  end;
  writeln(s);
 end;
 close(input);close(output);
end.