Factorial Big
JavaScript
Easy
3 views
Problem Description
Given n, print n! (factorial). Use loop and BigInt because number can be big.
Input Format
One integer n.
Output Format
One big integer (n!).
Official Solution
const fs=require('fs');const s=fs.readFileSync(0,'utf8').trim();if(!s)process.exit(0);const n=Number(s);let ans=1n;for(let i=2;i<=n;i++)ans*=BigInt(i);process.stdout.write(ans.toString());
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!