RosettaCodeData/Task/Greatest-common-divisor/Euler-Math-Toolbox/greatest-common-divisor.euler
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

13 lines
276 B
Text

>ggt(123456795,1234567851)
33
>function myggt (n:index, m:index) ...
$ if n<m then {n,m}={m,n}; endif;
$ repeat
$ k=mod(n,m);
$ if k==0 then return m; endif;
$ if k==1 then return 1; endif;
$ {n,m}={m,k};
$ end;
$ endfunction
>myggt(123456795,1234567851)
33