Cod sursa(job #150486)
| Utilizator | Data | 6 martie 2008 23:34:52 | |
|---|---|---|---|
| Problema | Fractii | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
var f:text;
n,j,i,s,r,a,b:longint;
ok:boolean;
begin
assign(f, 'fractii.in');
reset(f);
read(f,n);
s:=n;
close(f);
for i:=2 to n do
begin
j:=2;
s:=s+1;
for j:=1 to n do
begin
ok:=true;
if i>j then
begin
a:=i;
b:=j;
end
else
begin
a:=j;
b:=i;
end;
r:=a mod b;
while r<>0 do
begin
a:=b;
b:=r;
r:=a mod b;
end;
if (i=b) or (j=b) then
ok:=false;
if ok=true then
s:=s+1;
end;
end;
assign(f, 'fractii.out');
rewrite(f);
write(f,s);
close(f);
end.
