We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d1f6136 commit 0a18b33Copy full SHA for 0a18b33
1 file changed
Basic Codes/factorial-by-loops.java
@@ -1,3 +1,6 @@
1
+//Question: You have to make an algorithm to find factorial of a given number;
2
+
3
+//factorial of n is n*(n-1)*.....*2*1;
4
package com.company;
5
6
import java.util.Scanner;
@@ -9,9 +12,10 @@ public Factorial() {
9
12
public static void main(String[] args) {
10
13
Scanner in = new Scanner(System.in);
11
14
System.out.println("you want factorial of which number");
15
16
+ //input of given number
17
int n = in.nextInt();
18
int fact = 1;
-
19
for(int i = n; 1 <= i; --i) {
20
fact *= i;
21
}
0 commit comments