Pagini recente » Cod sursa (job #69083) | Cod sursa (job #611149) | Cod sursa (job #3193022) | Cod sursa (job #2589008) | Cod sursa (job #288895)
Cod sursa(job #288895)
Utilizator |
Birsan Dragos hominidu |
Data |
26 martie 2009 10:38:00 |
Problema |
Frac |
Scor |
20 |
Compilator |
fpc |
Status |
done |
Runda |
aa |
Marime |
0.42 kb |
var f,g:text;
a,b:longint;
ct,ct2:longint;
function cmmdc(m,n:longint):longint;
var r:longint;
begin
repeat
begin
r:=m mod n;
m:=n;
n:=r;
end;
cmmdc:=m;
until r<=0;
end;
BEGIN
assign(f,'frac.in');
reset(f);
read(f,a,b);
close(f);
ct:=0; ct2:=0;
while ct2 < b do
begin
ct:=ct+1;
if cmmdc(ct,a) = 1 then
ct2:=ct2+1;
end;
assign(g,'frac.out');
rewrite(g);
writeln(g,ct);
close(g);
END.