Skip to content

Instantly share code, notes, and snippets.

@kinow
Created November 4, 2011 20:08
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 kinow/1340351 to your computer and use it in GitHub Desktop.
Save kinow/1340351 to your computer and use it in GitHub Desktop.
bruno.py with division
#!/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