Trains the technique from
LeetCode 2652Sum MultiplesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A tally sheet is marked 1 through n.
A mark is struck off when it divides evenly by 3, by 5 or by 7. Return the total of the marks struck off.
Example 1
Every multiple of 3, 5 or 7 up to 143 is struck off, and their total comes to this once the overlaps have been settled.
Example 2
The marks struck off are 3, 5, 6, 7, 9, 10, 12, 14 and 15, which total 81. The mark 15 divides by both 3 and 5 yet is counted once.
Example 3
Neither mark divides by 3, 5 or 7.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def sum_of_multiples(n: int) -> int:public int sumOfMultiples(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.