Skip to content

Commit

Permalink
Problem 1
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinzamaninasab committed Sep 11, 2020
1 parent a978e6a commit 1f1c0d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Multiples of 3 and 5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sum_multiples = 0 # we should put this outside for loop not inside
for i in range(1, 1000): # at first set range(1, 10) to see what happens and debugging would be much easier
# print(i) # to make sure that our program works fine!
if i % 3 == 0 or i % 5 == 0: # check if they are multiples of 3 & 5 or not
# print(i) # make sure we got right numbers
sum_multiples += i # add i to sum_multiple each time
print(sum_multiples)

1 comment on commit 1f1c0d7

@hosseinzamaninasab
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Please sign in to comment.