-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP29.java
More file actions
33 lines (29 loc) · 704 Bytes
/
Copy pathP29.java
File metadata and controls
33 lines (29 loc) · 704 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
/**
* Project Euler #29 solution
*
* by Jayant Sinha
*
*/
import java.io.IOException;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Iterator;
public class P29 {
public static void main(String[] args) throws IOException {
HashSet<BigInteger> hs = new HashSet<BigInteger>();
BigInteger A;
for (long a = 2; a<=100;a++){
for (int b=2;b<=100;b++){
A = BigInteger.valueOf(a);
hs.add(A.pow(b));
}
}
Iterator itr = hs.iterator();
int sum = 0;
while(itr.hasNext()){
sum+=1;
itr.next();
}
System.out.println(sum);
}
}