Created
May 13, 2014 21:28
-
-
Save goyuninfo/88bd7008f8e1cd3b683a to your computer and use it in GitHub Desktop.
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
/** | |
* | |
* @author i88.ca | |
*/ | |
public class ProjectEuler1 { | |
public static void main(String[] args) { | |
int s = sumDivisibleBy(3) + sumDivisibleBy(5) - sumDivisibleBy(15); | |
System.out.println(s); | |
} | |
public static int sumDivisibleBy(int n) { | |
int p = 999 / n; | |
return n * (p * (p + 1)) / 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment