Created
January 26, 2019 07:06
-
-
Save afrieirham/80198c8243db3dae9d9a8f4c7a10c1e8 to your computer and use it in GitHub Desktop.
Solution for Project Euler #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void problem1(){ | |
Set<Integer> multiples = new HashSet<Integer>(); | |
for(int i=1; i<1000; i++){ | |
if(i%3==0 || i%5==0){ | |
multiples.add(i); | |
} | |
} | |
Integer[] numbers = multiples.toArray(new Integer[multiples.size()]); | |
int total = 0; | |
for(int i=0; i<numbers.length; i++){ | |
total += numbers[i]; | |
} | |
System.out.println(total); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment