Skip to content

Instantly share code, notes, and snippets.

@Winwardo
Created August 28, 2011 16:30
Show Gist options
  • Save Winwardo/1176873 to your computer and use it in GitHub Desktop.
Save Winwardo/1176873 to your computer and use it in GitHub Desktop.
Sum of all multiples of 3 and 5 below 1000
sum1 = 0;
for i in range(3,1000):
if( ((i % 3) == 0) or ((i % 5) == 0) ):
sum1 += i
print "The sum is",sum1
print sum(x for x in range(3,100))
print sum(y for y in range(3,1000) if not(y%3) or not(y%5))
#print sum(x for x in xrange(1,1000) if x % 3 == 0 or x % 5 == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment