Sum of Multiples of X Divisible by Y
EasyP3Coding
Take the first k multiples of x, that is x, 2x, ..., kx. Return the sum of those that are divisible by y.
Example 1
- Input
- x = 2, y = 4, k = 5
- Output
- 12
- Why
- The multiples are 2, 4, 6, 8, 10. Those divisible by 4 are 4 and 8, sum 12.
Example 2
- Input
- x = 3, y = 3, k = 4
- Output
- 30
Example 3
- Input
- x = 5, y = 7, k = 3
- Output
- 0
Constraints
- 1 <= x, y <= 10^4
- 1 <= k <= 10^4
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.