Greatest common divisor: Difference between revisions
Content added Content deleted
(→Recursive: use the UInt type and the constraint in a proto) |
|||
Line 2,322: | Line 2,322: | ||
===Recursive=== |
===Recursive=== |
||
<lang perl6> |
<lang perl6>multi gcd (0, 0) { fail } |
||
multi gcd ($a, 0) { $a } |
multi gcd (Int $a, 0) { abs $a } |
||
multi gcd ($a, $b) { gcd $b, $a % $b }</lang> |
multi gcd (Int $a, Int $b) { gcd $b, $a % $b }</lang> |
||
===Concise=== |
===Concise=== |