2752. Sum Multiples
My accepted Python solution to LeetCode problem 2752, Sum Multiples, running in 25ms.
- Difficulty: Easy
- Python
- Runtime 25ms
- Memory 17.4MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 25ms, memory 17.4MB, accepted 2025-12-31.
class Solution:
def sumOfMultiples(self, n: int) -> int:
return sum(i for i in range(1, n + 1) if i % 3 == 0 or i % 5 == 0 or i % 7 == 0)