Sum of multiples of 3 and 5¶
The following problem was inspired by Problem 1 at Project Euler.
If you list all the natural numbers below 10 that are multiples of 3 or 5, you get 3, 5, 6, and 9. The sum of these multiples is 23. Define a function according to the following definition:
Return the sum of all multiples of 3 and 5 below n.
Parameters: n (int) – The number up to which the sum of multiples of 3 and 5 is computed. Returns: The sum of all multiples of 3 and 5 up to n. Return type: int
Start by downloading the
exercise template and
editing this file. You can run tests via
$ python sum_of_multiples_of_3_and_5.py test
to check whether you got a correct solution. You can also take a look at
one possible solution.