-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq26.java
More file actions
38 lines (33 loc) · 711 Bytes
/
q26.java
File metadata and controls
38 lines (33 loc) · 711 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
import java.math.*;
import java.util.*;
import helpers.helpers;
public class q26 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int max = 1;
int value = 1;
for(int i = 2; i < 1001; ++i){
int m = i;
while(m%2 == 0){
m /= 2;
}
while(m%5 == 0){
m /= 5;
}
int k = lengthRepeat(m);
if( k > max){
max = k;
value = i;
}
}
System.out.println(value);
}
public static int lengthRepeat(int mantissa){
BigDecimal i = new BigDecimal(9);
while(i.remainder(BigDecimal.valueOf(mantissa)) != BigDecimal.ZERO){
i = i.multiply(BigDecimal.valueOf(10));
i = i.add(BigDecimal.valueOf(9));
}
return i.toString().length();
}
}