Pagini recente » Cod sursa (job #2549262) | Cod sursa (job #861358) | Cod sursa (job #3033597) | Cod sursa (job #589136) | Cod sursa (job #345174)
Cod sursa(job #345174)
program fractii;
var n,q,i,l,d,r,p:longint;f,g:text;
begin
assign(f,'fractii.in');reset(f);
assign(g,'fractii.out');rewrite(g);
readln(f,n);p:=1;
repeat
inc(q);
if p>q then begin d:=p;i:=q; end else begin d:=q;i:=p;end;
r:=d mod i;
while r<>0 do begin
d:=i;
i:=r;
r:=d mod i;end;
if i=1 then inc(l);if q=n then begin inc(p);q:=0;end;
until p=n+1;
write(g,l);
close(f);
close(g);
end.