Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • How about

    sub fact
    {
            my ( $n ) = @_;

            my @s = ();
            $s[0] = 1;

            foreach my $m ( 1 .. $n )
            {
                    $s[$m] = 0;
                    for( my $k = $m;$k>=1;$k--)
                    {
                            foreach my $i ( 1 .. $k )
                            {
                                    $s[$i] += $s[$i-1];
                            }
                    }
            }
            return $s[$n];
    }

    Loads more available at http://www.luschny.de/math/factorial/FastFactorialFunctions.htm [luschny.de]