Help for this page

Select Code to Download


  1. or download this
        # A classic, recursive soulution.
        sub Rfactorial {
    ...
            return 1 if $i == 1;
            return $i * Rfactorial($i - 1);
        }
    
  2. or download this
        # Tail recursive
        sub factorial {
    ...
                fact( $n-1, $n*$a );
            }
        }