Ad

Write a function that accepts an integer (n) and calculates the multiples of 4 or 6 up to n but not including the input number n.

Return the sum of those multiples.

For example:

n = 20 ==> 64

n = 35 ==> 198

n = 120 ==> 2340

Code
Diff
  • def find_multiples(n):
        total = 0
        for i in range(0, n, 2):
            if i % 4 == 0 or i % 6 == 0:
                total += i
        return total
    
    
    • def find_multiples(n):
    • total = 0
    • for i in range(0, n, 2):
    • if i % 4 == 0 or i % 6 == 0:
    • total += i
    • return total
    • return total