Created
June 5, 2011 14:03
-
-
Save behrangsa/1008983 to your computer and use it in GitHub Desktop.
Project Euler, Question 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
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