We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0731cc2 commit 4b3a0edCopy full SHA for 4b3a0ed
Repetition Problems/For Loop/Factorial.js
@@ -0,0 +1,13 @@
1
+/*
2
+ Write a program that computes a factorial of a number taken as input.
3
+ 5 Factorial => 5! = 1 * 2 * 3 * 4 * 5
4
+*/
5
+
6
+const prompt = require("prompt-sync")();
7
+console.log();
8
+let number = parseInt(prompt(" Enter the number : "))
9
+let factorial = 1;
10
+for (let i = 1; i <= number; i++) {
11
+ factorial = factorial * i;
12
+}
13
+console.log(" Factorial of " + number + " = " + factorial + "\n");
0 commit comments