Skip to content

Commit bcd8dde

Browse files
authored
Java Program - Find Factorial of Number
1 parent c2af867 commit bcd8dde

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Test22_Find_Factorial_of_Number.java

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.test.Basic_Java_Programs;
2+
3+
import java.util.Iterator;
4+
import java.util.Scanner;
5+
6+
public class Test22_Find_Factorial_of_Number
7+
{
8+
public static void main(String[] args)
9+
{
10+
int n, fact = 1;
11+
12+
System.out.print("Enter a Number : ");
13+
14+
Scanner sc = new Scanner(System.in);
15+
16+
n = sc.nextInt();
17+
18+
for (int i = 1; i<= n; i++)
19+
{
20+
fact = fact*i;
21+
}
22+
System.out.println("Factorial : " + fact);
23+
24+
}
25+
26+
}
27+
28+
// Output :
29+
/*
30+
31+
Enter a Number : 10
32+
Factorial : 3628800
33+
34+
35+
36+
37+
*/

0 commit comments

Comments
 (0)