Problem 136965 · easy · Phase 01 Prerequisites & Setup

Sum of Multiples of 3 or 5

loops · range · modulo · accumulation

Write sum_multiples(n) that adds up every positive integer below n that is a multiple of 3 or of 5 (or both) and returns the sum.

Examples

Input:  n = 10
Output: 23
Explanation: 3 + 5 + 6 + 9 = 23

Input:  n = 3
Output: 0

Constraints

  • 0 <= n <= 10**5

Goals

  • Combine a loop with an or-condition
  • Sum only the numbers that pass a test
Starting Python…