Calculate the factorial of big numbers.
Switch branches/tags
Nothing to show
Latest commit 5c3899c Jun 14, 2014 @KenanY KenanY Release 1.0.2
Failed to load latest commit information.
test Initial commit Sep 8, 2013
.gitattributes Initial commit Sep 8, 2013
.gitignore Initial commit Sep 8, 2013
.travis.yml Raise git clone depth in Travis Jun 22, 2014
LICENSE.txt 2014 Jan 1, 2014 Explicitly use Gemnasium's SVG badge Jun 22, 2014
index.js Initial commit Sep 8, 2013
package.json Release 1.0.2 Jun 22, 2014


Build Status Dependency Status

Like factorial but for big numbers. Inspired by a blog post by Reginald Braithwaite (@raganwald).


If you want to find the factorial of an integer less than 171, then you don't need this module. Otherwise, you do need it:

var factorial = require('factorial');

// => 7.257415615307994e+306

// => Infinity

// => RangeError: Maximum call stack size exceeded

The Infinity problem is a result of JavaScript's limit on how big numbers can be. This module solves this problem by using big-integer.

The RangeError is a problem with how the factorial is calculated. The recursion used goes so deep that it exceeds the limit that Node.js has. As described in Reginald's blog post, this problem is solved by using trampolines.


$ npm install big-factorial


var bigFactorial = require('big-factorial');


Returns the factorial of value as a bigInt, where value is either a Number or a String.