Created
November 4, 2011 20:08
-
-
Save kinow/1340351 to your computer and use it in GitHub Desktop.
bruno.py with division
This file contains hidden or 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
#!/usr/bin/env python | |
if __name__ == '__main__': | |
total = 0 # total of the multiples of 3 or 5 seen so far | |
n = 1000 # the length of the range to be tested | |
next_mult_3 = 0 # the next multiple of 3 to be considered | |
next_mult_5 = 0 # the next multiple of 5 to be considered | |
i = 0 | |
while i < n: | |
if i % 3 == 0: | |
total += i | |
elif i % 5 == 0: | |
total += i | |
i+=1 | |
print total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment