Anonymous user
Greatest common divisor: Difference between revisions
Euclid's gcd in Hoon
imported>Msicilia (Euclid's gcd in Hoon) |
|||
Line 3,705:
ENDIF
END</syntaxhighlight>
=={{header|Hoon}}==
<syntaxhighlight lang="haskell">::
:: Greatest common divisor (gcd), Euclid's algorithm.
::
|= [a=@ud b=@ud]
^- @ud
?> (gth b 0)
?: =((mod a b) 0)
b
$(a b, b (mod a b))</syntaxhighlight>
<pre>
> (gcd 123 36)
3
</pre>
=={{header|Icon}} and {{header|Unicon}}==
|