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]
    }