Skip to content

Instantly share code, notes, and snippets.

@behrangsa
Created June 5, 2011 14:03
Show Gist options
  • Save behrangsa/1008983 to your computer and use it in GitHub Desktop.
Save behrangsa/1008983 to your computer and use it in GitHub Desktop.
Project Euler, Question 1
package org.behrang.euler.q1;
public class Main {
public static void main(String[] args) {
long answer = 0;
for (int i = 0; i < 1000; i++) {
if (i % 3 == 0 || i % 5 == 0) {
answer += i;
}
}
System.out.println("Sum of numbers between 0 and less than 1000 that are divisible by 5 or 3 is: " + answer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment