forked from nayuki/Project-Euler-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp029.java
More file actions
30 lines (23 loc) · 662 Bytes
/
p029.java
File metadata and controls
30 lines (23 loc) · 662 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
/*
* Solution to Project Euler problem 29
* By Nayuki Minase
*
* http://nayuki.eigenstate.org/page/project-euler-solutions
* https://github.com/nayuki/Project-Euler-solutions
*/
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Set;
public final class p029 implements EulerSolution {
public static void main(String[] args) {
System.out.println(new p029().run());
}
public String run() {
Set<BigInteger> generated = new HashSet<BigInteger>();
for (int a = 2; a <= 100; a++) {
for (int b = 2; b <= 100; b++)
generated.add(BigInteger.valueOf(a).pow(b));
}
return Integer.toString(generated.size());
}
}