package margusmartseppcode.From_40_to_49;
public class Problem_40 {
public static void main(String[] args) {
int size = 100000, result = 1;
StringBuilder sb = new StringBuilder(size + 200);
for (int i = 1; sb.length() <= 100000; i++)
sb.append(i);
for (int count = 1; count <= size; count *= 10)
result *= Character.getNumericValue(sb.charAt(count - 1));
System.out.println(result);
}
}
Showing posts with label fraction. Show all posts
Showing posts with label fraction. Show all posts
Wednesday, September 9, 2009
Euler Problem 40 solution
Time (s): ~0.008
Labels:
Euler Problem 40-49,
fraction,
irrational number,
Strings
Tuesday, September 8, 2009
Euler Problem 33 solution
Time (s): ~0.001
package margusmartseppcode.From_30_to_39;
public class Problem_33 {
public static void main(String[] args) {
int d = 1;
double ii;
for (int i = 1; i < 10; i++)
for (int j = 1; j < i; j++)
for (double k = 1; k < j; k++) {
ii = (i * 10 + j) / (k * 10 + i);
if (ii == j / k)
d *= ii;
}
System.out.println(d);
}
}
Subscribe to:
Posts (Atom)