A few notes to increase the performance INSIGNIFICANTLY: - Calculating `MULTIPLES[0]*MULTIPLES[1]` two times can be avoided by using a variable. - Using Bitwise operation `>>2` to divide the product of `i * (i+1)`. - Calculating `MAX_NUMBER - 1` 2 times can be avoided as well. To make the program generic for multiple multiples, you may have to make manifold changes i.e - to get pairs, triples, etc => All permutation of lengths `1` to `multiples.size()`. - Decide when to add or subtract. Suggestion would be to check the formula for size 3,4,5; Conclude a generic formula instead of if checks for each length and then extend it. Do include if the `multiples` size is 1 :-)