Skip to content

Instantly share code, notes, and snippets.

@DawTaylor
Created October 7, 2017 19:45
Show Gist options
  • Save DawTaylor/a169ef6e1d8106e0247cfee9db2cb738 to your computer and use it in GitHub Desktop.
Save DawTaylor/a169ef6e1d8106e0247cfee9db2cb738 to your computer and use it in GitHub Desktop.
Simple JS factorial implementation
const factorial = n => (n <= 1) ? 1 : n * factorial(n - 1);
let n = process.argv[2];
console.log(`Factorial of ${n} = ${factorial(n)}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment