Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Euclidean algorithm Golf in Perl 6

by moritz (Cardinal)
on Jun 18, 2009 at 16:28 UTC ( #772778=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        while $b != 0 {
            ($b, $a) = ($a % $b, $b);
        }
    
  2. or download this
    sub gcd ($a, $b) {
        return $a if !$b;
    ...
    }
    
    say gcd(24, 42);
    
  3. or download this
    sub gcd ($a, $b) {
        ($a, $b ... { $^x % $^y || () })[*-1]
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://772778]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2014-11-24 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (141 votes), past polls