Skip to content

Instantly share code, notes, and snippets.

@Hoyasumii
Last active August 23, 2024 14:47
Show Gist options
  • Save Hoyasumii/59fc24bd7693bdeb155034a3183c3c9e to your computer and use it in GitHub Desktop.
Save Hoyasumii/59fc24bd7693bdeb155034a3183c3c9e to your computer and use it in GitHub Desktop.
Factorial Alghoritm for JavaScript
const factorial = (number) => {
if (number <= 1) return 1;
return BigInt(number) * BigInt(factorial(number - 1));
}
console.time("res");
console.log(factorial(31_931))
console.timeEnd("res");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment