Created
August 28, 2011 16:30
-
-
Save Winwardo/1176873 to your computer and use it in GitHub Desktop.
Sum of all multiples of 3 and 5 below 1000
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
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