forked from bliblidotcom/training-java-future-program
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactorial.java
More file actions
Latest commit
20 lines (19 loc) · 493 Bytes
/
Copy pathFactorial.java
File metadata and controls
20 lines (19 loc) · 493 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
publicclassFactorial{
publicstaticvoidmain(String[] args){
if(args.length != 1){
System.out.println("Usage: Factorial <number>");
return;
}
inttotal = 1;
intfact = Integer.parseInt(args[0]);
for(inti=1; i<=fact; i++){
if(fact == 0){
total = 1;
}
else{
total*= i;
}
}
System.out.println("Jumlah factorial adalah: " + total);
}
}