-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem11.java
More file actions
43 lines (35 loc) · 781 Bytes
/
Problem11.java
File metadata and controls
43 lines (35 loc) · 781 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
33
34
35
36
37
38
39
40
41
42
43
package dimikOJ;
import java.util.Scanner;
public class Problem11 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int T = input.nextInt();
while (T < 1) {
T = input.nextInt();
}
int[] N = new int[T];
for (int i = 0; i < N.length; i++) {
N[i] = input.nextInt();
while (N[i] < 0 || N[i] > 15) {
N[i] = input.nextInt();
}
}
input.close();
for (int i : N) {
System.out.println(factorial(i));
}
}
public static long factorial(int number) {
if (number == 0) {
return 1;
}
else {
long factorial = 1;
for (int i = number; i >= 1; i--) {
factorial = factorial * i;
}
return factorial;
}
}
}