Skip to content

Commit 0a18b33

Browse files
authored
Update factorial-by-loops.java
1 parent d1f6136 commit 0a18b33

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Basic Codes/factorial-by-loops.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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;
14
package com.company;
25

36
import java.util.Scanner;
@@ -9,9 +12,10 @@ public Factorial() {
912
public static void main(String[] args) {
1013
Scanner in = new Scanner(System.in);
1114
System.out.println("you want factorial of which number");
15+
16+
//input of given number
1217
int n = in.nextInt();
1318
int fact = 1;
14-
1519
for(int i = n; 1 <= i; --i) {
1620
fact *= i;
1721
}

0 commit comments

Comments
 (0)