Sum of multiples of 3 or 5

Write code · Basic · §2.2 Divisors and multiples

Complete the function solution, which returns the sum of all the positive integers from 1 to n that are multiples of 3 or multiples of 5. n itself is included.

A number that is a multiple of both 3 and 5, such as 15, is added only once.

Function

solution(n)

Constraints

Examples

nresult
1033
1560

Starter code

def solution(n):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.