Skip to content

Instantly share code, notes, and snippets.

@afrieirham
Created January 26, 2019 07:06
Show Gist options
  • Save afrieirham/80198c8243db3dae9d9a8f4c7a10c1e8 to your computer and use it in GitHub Desktop.
Save afrieirham/80198c8243db3dae9d9a8f4c7a10c1e8 to your computer and use it in GitHub Desktop.
Solution for Project Euler #1
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