1const factorial = n => n <= 1 ? 1 : n * factorial(n - 1);
2
3// Examples
4factorial(2); // 2
5factorial(3); // 6
1var factorial = function(n){n=BigInt(n);return (n==0n||n==1n)?1n:factorial(n-1n)*n;}
2//can be print this way
3console.log( factorial(n) );