- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactorial.java
More file actions
Latest commit
19 lines (15 loc) · 416 Bytes
/
Copy pathFactorial.java
File metadata and controls
19 lines (15 loc) · 416 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
packagecom.sarvesh.javabasics;
importjava.util.Scanner;
publicclassFactorial {
publicstaticvoidmain(String[] args) {
Scannersc = newScanner(System.in);
System.out.print("Enter a Number : ");
intnumber = sc.nextInt();
longfactorial = 1;
for (inti = 1; i <= number; i++) {
factorial *= i;
}
System.out.println("Factorial of " + number + " is: " + factorial);
sc.close();
}
}