Skip to main content

You are provided with a number, "N". Find its factorial.

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

Popular posts from this blog

Let "A" be a string. Remove all the whitespaces and find it's length.

Let " A "  be a string. Remove all the whitespaces and find it's length. Input Description: A string is provide as an input Output Description: Remove all the whitespaces and then print the length of the remaining string. Sample Input : Lorem Ipsum Sample Output : 10 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 =''; for(i=0;i<data.length;i++) a=a+data[i]; console.log(a.length) });

You are provided with the radius of a circle "A". Find the length of its circumference.

You are provided with the radius of a circle "A". Find the length of its circumference. Note: In case the output is coming in decimal, roundoff to 2nd decimal place. In case the input is a negative number, print "Error". Input Description: The Radius of a circle is provided as the input of the program. Output Description: Calculate and print the Circumference of the circle corresponding to the input radius up to two decimal places. Sample Input : 2 Sample Output : 12.57 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 = parseFloat(data[0]); var b = (2*3.142*a) if(a>=-1) console.log(b.toFixed(2)); else console.log("error") });

You are given with a number A i.e. the temperature in Celcius. Write a program to convert this into Fahrenheit.

You are given with a number  A  i.e. the temperature in Celcius. Write a program to convert this into Fahrenheit.  Note: In case of decimal values, round-off to two decimal places. Input Description: A number is provided in Celcius as the input of the program. Output Description: The output shall be the temperature converted into Fahrenheit corresponding to the input value print up to two decimal places and round off if required. Sample Input : 12 Sample Output : 53.60 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 b=(a*1.8+32); console.log(b.toFixed(2)); });