Help for this page

Select Code to Download


  1. or download this
        sub fib (Int $n) {
            return 1 if $n < 2;
            state @seen[$n] //= fib($n-1) + fib($n-2);
        }
    
  2. or download this
        sub fib (Int $n) {
            $n < 2 or state @seen[$n] //= fib($n-1) + fib($n-2);
        }
    
  3. or download this
        my&fib:={$_<2or state@s[$_]//=fib($_-1)+fib $_-2}