-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem040.java
More file actions
23 lines (23 loc) · 838 Bytes
/
Problem040.java
File metadata and controls
23 lines (23 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.ArrayList;
import java.util.Arrays;
public class Problem040 {
public static void main(String[] args) {
ArrayList<String> nums = new ArrayList<String>(1000000);
int i = 1;
while (nums.size() <= 1000000) {
nums.addAll(Arrays.asList(String.valueOf(i).split("")));
i++;
if (i % 1000 == 0) {
System.out.println(nums.size());
}
}
int total = Integer.parseInt(nums.get(0));
total *= Integer.parseInt(nums.get(9));
total *= Integer.parseInt(nums.get(99));
total *= Integer.parseInt(nums.get(999));
total *= Integer.parseInt(nums.get(9999));
total *= Integer.parseInt(nums.get(99999));
total *= Integer.parseInt(nums.get(999999));
System.out.println(total);
}
}