FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 11   



Following program shows you how to print factorial of given number.
In this program we get input from user and prints factorial of that number using for loop

var input = parseInt(prompt("Please enter a number:"));
var result = 1;
for (var i = 1; i <= input; i++) {
result = result * i;
}
console.log(input + " factorial is: " + result);
`

Output:

Please enter a number:
5
5 factorial is: 120



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News