public static int sumOfMultiples(int i, int j, int limit){
int s = --limit / i, t = limit / j, u = limit / (i * j);
return (i*(s*(s+1)/2)) + (j*(t*(t+1)/2)) - ((i*j)*(u*(u+1)/2));
}
Test
actual = Prob1.sumOfMultiples(3, 5, 1000);
assertEquals(233168, actual);