Problem 136965 · easy · Level 01 Prerequisites & Setup

Raffle Prizes for Threes and Fives

loops · range · modulo · accumulation

The school fair sells raffle tickets numbered 1, 2, 3, and so on. Every ticket numbered below n whose number divides exactly by 3 or by 5 (or by both) wins that many pence: ticket 9 wins 9p. Write sum_multiples(n) that returns the total prize money in pence, which is the sum of those ticket numbers.

Examples

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

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…