You are provided with a number, "N". Find its factorial.
Input Description:
A positive integer is provided as an input.
Output Description:
Print the factorial of the integer.
Sample Input :
2
Sample Output :
2
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var a = parseInt(data[0]);
var factorial=1;
for(i=1;i<=a;i++)
factorial=factorial*i;
console.log(factorial)
});
Comments
Post a Comment