Pagini recente » Cod sursa (job #2168850) | Cod sursa (job #1759158) | Cod sursa (job #96771) | Cod sursa (job #3247223) | Cod sursa (job #326566)
Cod sursa(job #326566)
Program P1;
uses crt;
var i,j,t,n : longint;
f,g : text;
Function euclid(a,b : longint) : longint;
var k : longint;
begin
while (a mod b<>0) do
begin
k:=a mod b;
a:=b;
b:=k;
end;
euclid:=k;
end;
function ireductibil(a,b : longint) : boolean;
var k : longint;
begin
if (a=1) and (b=1) then exit(true);
if (b=1) or (a=1) then exit(true);
if a=b then exit(false);
if a>b then begin if a mod b=0 then exit(false); end
else if b mod a=0 then exit(false);
k:=euclid(a,b);
if k=1 then ireductibil:=true else ireductibil:=false;
end;
begin
clrscr;
t:=0;
assign(f,'fractii.in'); assign(g,'fractii.out');
reset(f); rewrite(g);
readln(f,n);
close(f);
for i:=1 to n do
for j:=1 to n do
if ireductibil(i,j) then inc(t);
writeln(g,t);
close(g);
end.