-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0019.java
More file actions
32 lines (28 loc) · 865 Bytes
/
Copy path0019.java
File metadata and controls
32 lines (28 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
//ファイル名がMain.javaでないとコンパイルできないが、管理が面倒なのでファイル名を変更している。
public class Main {
public static BigDecimal fact(BigDecimal n){
if(n.compareTo(new BigDecimal(1)) > 0){
return n.multiply(fact(n.subtract(new BigDecimal(1))));
}else{
return new BigDecimal(1);
}
}
public static void main(String[] args) {
BigDecimal ans = null;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
ans = new BigDecimal(Integer.parseInt(br.readLine()));
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(ans != null){
System.out.println(fact(ans));
}
}
}