Pages

Tuesday, September 8, 2009

Euler Problem 29 solution

Time (s): ~0.025
package margusmartseppcode.From_20_to_29;

import java.util.HashSet;
import java.util.Set;

public class Problem_29 {

 public static void main(String[] args) {
  int max = 101;
  Set<double> set = new HashSet<double>();

  for (Long i = 2L; i < max; i++)
   for (Long j = 2L; j < max; j++)
    set.add(Math.pow(i, j));

  System.out.println(set.size());
 }
}

No comments:

Post a Comment