Skip to content

Commit 70c8c4e

Browse files
Merge pull request #171 from deepanshu1201/main
factorial
2 parents b905ea9 + a5bc350 commit 70c8c4e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

factorial.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.Scanner;
2+
3+
public class factorial {
4+
public static void main(String[] args) {
5+
Scanner in = new Scanner(System.in);
6+
System.out.print("Input a number: ");
7+
int n = in.nextInt();
8+
in.close();
9+
int fact = 1;
10+
11+
while(n>0){
12+
fact= fact*n;
13+
n--;
14+
}
15+
System.err.println("factorial of your number is = " + fact );
16+
}
17+
18+
19+
}

0 commit comments

Comments
 (0)