1: Multiples of 3 or 5#
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
Your Solution#
Lunch this notebook and try to create your own solution!
Tip: look for the launch button (🚀) in the top right corner!
def problem1(N):
# Try your solution here
return solution
# Testing:
unittest.main(argv=[''], verbosity=2,exit=False)
# Printing Project Euler Solution
# print(problem1(1_000))
My solution#
Spoiler Alert!!
See my solution bellow
def problem1(N):
solution = 0
for i in range(N):
if i % 3 == 0 or i % 5 == 0:
solution += i
return solution
unittest.main(argv=[''], verbosity=2,exit=False)
The sum of all the multiples of 3 or 5 below 1000 is:
problem1(1_000)
233168