Skip to content

Commit 1d88b4c

Browse files
authored
Create abc
1 parent b803756 commit 1d88b4c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

abc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.util.stream.LongStream;
2+
import java.io.BufferedReader;
3+
import java.io.InputStreamReader;
4+
import java.math.BigInteger;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
8+
public class HelloWorld{
9+
10+
public static void main(String args[]) throws Exception {
11+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
12+
String line = br.readLine();
13+
int N = Integer.parseInt(line);
14+
ArrayList<Integer> inputs = new ArrayList<Integer>();
15+
for (int i = 0; i < N; i++) {
16+
inputs.add(Integer.valueOf(br.readLine()));
17+
}
18+
ArrayList<BigInteger> outputs = new ArrayList<BigInteger>();
19+
for(Integer input : inputs){
20+
outputs.add(factorial(input));
21+
}
22+
for(BigInteger result: outputs){
23+
System.out.println(result);
24+
}
25+
}
26+
27+
private static BigInteger factorial(Integer input) {
28+
if(input == 1) return BigInteger.ONE;
29+
return factorial(input - 1).multiply(new BigInteger(String.valueOf(input)));
30+
}
31+
}

0 commit comments

Comments
 (0)