Search code examples
perlbignum

How can I compute double factorials in Perl?


Given Wikipedia's discussion of Double Factorials, can anyone suggest where I might find a bignum version of this for Perl, or else suggest how it might be written?


Solution

  • Perl will handle whatever your C compiler can handle, for anything bigger you should be using Math::BigInt.

    I would recommend you read perlnumber.

    A definition for the double factorial (in perl golf):

    sub f{$_[0]&&$_[0]>=2?$_[0]*f($_[0]-2):1}