-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp40.java
More file actions
41 lines (33 loc) · 1.05 KB
/
p40.java
File metadata and controls
41 lines (33 loc) · 1.05 KB
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
import java.util.*;
public class p40 {
public static void main(String[] args){
int i = 1;
String istr = ((Integer) i).toString();
int count = 1;
int start = 1;
char[] tenpow = new char[7];
while(count <= 1000000){
if (count - start >= istr.length()){
i++;
start = count;
istr = ((Integer) i).toString();
}
char c = istr.charAt(count - start);
switch(count){
case 1: tenpow[0] = c; break;
case 10: tenpow[1] = c; break;
case 100: tenpow[2] = c; break;
case 1000: tenpow[3] = c; break;
case 10000: tenpow[4] = c; break;
case 100000: tenpow[5] = c; break;
case 1000000: tenpow[6] = c; break;
}
count++;
}
int prod = 1;
for (char c: tenpow){
prod *= Integer.valueOf(c - 48);
}
System.out.println(prod);
}
}