fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main(String[] args)
  11. {
  12. int[] multiplier = { 3, 5, 7 };
  13.  
  14. TreeSet<Integer> result = new TreeSet<Integer>();
  15. TreeSet<Integer> queue = new TreeSet<Integer>();
  16. queue.addAll(Arrays.asList(1));
  17. while (result.size() < 100)
  18. {
  19. int num = queue.pollFirst();
  20. result.add(num);
  21.  
  22. for (int i : multiplier)
  23. {
  24. queue.add(num * i);
  25. }
  26. }
  27.  
  28. System.out.println(result);
  29. }
  30. }
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
[1, 3, 5, 7, 9, 15, 21, 25, 27, 35, 45, 49, 63, 75, 81, 105, 125, 135, 147, 175, 189, 225, 243, 245, 315, 343, 375, 405, 441, 525, 567, 625, 675, 729, 735, 875, 945, 1029, 1125, 1215, 1225, 1323, 1575, 1701, 1715, 1875, 2025, 2187, 2205, 2401, 2625, 2835, 3087, 3125, 3375, 3645, 3675, 3969, 4375, 4725, 5103, 5145, 5625, 6075, 6125, 6561, 6615, 7203, 7875, 8505, 8575, 9261, 9375, 10125, 10935, 11025, 11907, 12005, 13125, 14175, 15309, 15435, 15625, 16807, 16875, 18225, 18375, 19683, 19845, 21609, 21875, 23625, 25515, 25725, 27783, 28125, 30375, 30625, 32805, 33075]