import java.util.*; import java.math.*; // How many distinct terms are in the sequence generated by ab for 2 a 100 and 2 b 100? public class Sol29 extends BaseSolution { public void runSolution() { Set termSet = new HashSet(); for (int a = 2; a <= 100; a++) { for (int b = 2; b <= 100; b++) { BigInteger term = new BigInteger(String.valueOf(a)).pow(b); termSet.add(term); } } System.out.println(termSet.size()); } }