Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.TreeSet;
- public class ThreesAndFivesSets {
- private static final int LIMIT = 10_000_000; // = 10^7
- public static void main(String[] args) {
- final TreeSet<Integer> integers = new TreeSet<>();
- for (int i = 3; i <= LIMIT; i+= 3) {
- integers.add(i);
- }
- for (int i = 5; i <= LIMIT; i+= 5) {
- integers.add(i);
- }
- System.out.println(integers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement