Pagini recente » Cod sursa (job #1624902) | Cod sursa (job #1622727) | Cod sursa (job #2309114) | Cod sursa (job #2707322) | Cod sursa (job #12186)
Cod sursa(job #12186)
var
n, r, i, j: longint;
f: text;
function Egyxusitheto(a,b:longint):boolean;
begin
Egyxusitheto:=true;
while a <> b do
begin
if a > b then Dec(a, (a div b) * b) else Dec(b, (b div a) * a);
if a = 0 then inc(a, b);
if b = 0 then inc(b, a);
end;
if a = 1 then egyxusitheto:=false;
end;
begin
Assign(f, 'fractii.in');
Reset(f);
ReadLn(f, n);
Close(f);
for i := 2 to n do
for j := 2 to n do
If Not(Egyxusitheto(i,j)) then inc(r);
Assign(f, 'fractii.out');
ReWrite(f);
Writeln(f, r+2*n-1);
Close(f);
end.