Cod sursa(job #256604)

Utilizator Gheorghe90Matrix Neo Gheorghe90 Data 11 februarie 2009 22:16:06
Problema Fractii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.62 kb
program fractie;
var i,j,n,t,l:integer;
    f:text;
    function divizor(x,y:integer):boolean;
    var i,o:integer;
    label 1;
    begin
    divizor:=false;
    if x<y then begin o:=x; x:=y; y:=o; end;
    for i:=y downto 2 do
    if (x mod i=0)and(y mod i=0) then
              begin divizor:=true; goto 1; end
              else divizor:=false;
    1:end;
begin
assign(f,'fractii.in');
reset(f);
readln(f,n);
close(f);
assign(f,'fractii.out');
rewrite(f); t:=n*n;
l:=0;
for i:=2 to n do
for j:=1 to n do
begin
if (i>1)and(j>1) then if divizor(i,j) then inc(l);
end;
t:=t-l;
writeln(f,t);
close(f);
end.