Skip to content

Latest commit

 

History

History
13 lines (11 loc) · 300 Bytes

2652.md

File metadata and controls

13 lines (11 loc) · 300 Bytes

2652. Sum Multiples

Solution 1 (time O(n), space O(1))

class Solution(object):
    def sumOfMultiples(self, n):
        """
        :type n: int
        :rtype: int
        """
        return sum(x for x in range(1, n + 1) if x % 3 == 0 or x % 5 == 0 or x % 7 == 0)