Skip to content

Instantly share code, notes, and snippets.

@goyuninfo
Created May 13, 2014 21:28
Show Gist options
  • Save goyuninfo/88bd7008f8e1cd3b683a to your computer and use it in GitHub Desktop.
Save goyuninfo/88bd7008f8e1cd3b683a to your computer and use it in GitHub Desktop.
/**
*
* @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