npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

bigint-factorial

v1.1.3

Published

Tiny factorial function using BigInt

Readme

bigint-factorial

npm npm bundle size David GitHub

Tiny factorial function using JavaScript's built-in BigInt

Factorials get very big, very quickly. Older packages for calculating them that use the number primitive internally suffer the following issues:

  • Subject to imprecision at factorials larger than 18 (at which point they surpass Number.MAX_SAFE_INTEGER)
  • Return Infinity at factorials larger than 170 (at which point they surpass Number.MAX_VALUE)

This package avoids these by dealing exclusively with the bigint primitive.

Install

Install with npm (or Yarn)

npm i bigint-factorial

Usage

  1. Import the package

    import factorial from 'bigint-factorial';
    // or
    const factorial = require('bigint-factorial');
  2. Calculate factorials

    factorial(5n);
    // ↪︎ 120n
    
    factorial(6n);
    // ↪︎ 720n
    
    factorial(7n);
    // ↪︎ 5040n
    
    factorial(183n);
    // ↪︎ 1211079010624906224171770242040000913194755344907123328387229208384122199143398983962077168073033852647945203036376445283346314711222230177466494273255728793463071956674839497876987299889729720327479783667584731115257659422804284707863129430806869565563037239578516564219715854442393339376435200000000000000000000000000000000000000000000n

API

factorial ⇒ bigint

Calculate the factorial of n

Returns: bigint - The factorial of n
Throws:

  • TypeError If n is not of type 'bigint'
  • RangeError If n is negative

| Param | Type | Description | | --- | --- | --- | | n | bigint | The number to calculate the factorial of |

System requirements

This package has been tested and confirmed to work on the above versions.

BigInt was added to Node.js in v10.4.0 with V8 release v6.7, therefore this package won't work in Node.js versions earlier than v10.4.0.