-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a978e6a
commit 1f1c0d7
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
1f1c0d7
There was a problem hiding this comment.
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.