Skip to content

Instantly share code, notes, and snippets.

@bonus85
Last active October 14, 2016 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonus85/659eff34563f753d199631a3236b9e85 to your computer and use it in GitHub Desktop.
Save bonus85/659eff34563f753d199631a3236b9e85 to your computer and use it in GitHub Desktop.
Project euler problem one solution
#!/usr/bin/env python
def sum_of_multiples_of_3_or_5(N):
s = 0
for i in range(N):
if i % 3 == 0 or i % 5 == 0: # Check if the number can be devided by 3 or 5
s += i # Add the number to the total sum
print "The sum of all numbers that are multiples of 3 and 5 below %d is:" %N
print s
if __name__ == '__main__':
sum_of_multiples_of_3_or_5(1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment