How about...?
($x, $y, * % * ... 0).[*-2]
- - - -
say ~(75, 18, *%* ... 0) # 75 18 3 0 say ~(162, 24, *%* ... 0) # 162 24 18 6 0
- → greatest common divisor is 2nd-to-last value
Perl 6 | Perl 6 series operator | #13 |
($x, $y, * % * ... 0).[*-2]
- - - -
say ~(75, 18, *%* ... 0) # 75 18 3 0 say ~(162, 24, *%* ... 0) # 162 24 18 6 0
Copyright © 2010 http://www.pmichaud.com/2010/pres/ |