Greatest common divisor: Difference between revisions

→‎Recursive: use the UInt type and the constraint in a proto
(→‎Recursive: use the UInt type and the constraint in a proto)
Line 2,322:
 
===Recursive===
<lang perl6>multiproto gcd (0UInt $a, UInt $b where $a|$b > 0) { fail *}
multi gcd (Int $a, 0) { abs $a }
multi gcd (Int $a, Int $b) { gcd $b, $a % $b }</lang>
 
===Concise===
1,934

edits