InVader wroteTo find the sum of multiples of m (not 0) less or equal to n:
Let c = n mod m
S(m,n) = Sum for i=0 -> i=(n-c)/m of m*i
S(m,n) = m * Sum for i=0 -> i=(n-c)/m of i
S(m,n) = m * (n-c)/m * ((n-c)/m + 1) / 2
S(m,n) = (n-c) * (n-c+m) / 2 / m
We have now a formula to get the sum of the multiples.
Now the final result is S(m1,n) + S(m2,n) - S(m3,n) where m3 is the lcm of m1 and m2.
Didn't really test the result though.
c(3, 532) = 532 mod 3 = 1
S(3, 532) = (532-1) * (532-1+3) / 2 / 3 = 47259
c(5, 532) = 532 mod 5 = 2
S(5, 532) = (532-2) * (532-2+5) / 2 / 5 = 28355
c(15, 532) = 532 mod 15 = 7
S(15, 532) = (532-7) * (532-7+15) / 2 / 15 = 9450
The rest is left as an exercise for the reader.