Created
October 28, 2013 18:33
-
-
Save garethjwilliams/7202128 to your computer and use it in GitHub Desktop.
Naive Python fizzbuzz with no divide or modulo.
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
| def fizzbuzz(stop): | |
| count_3 = count_5 = 0 | |
| for i in range(1, stop + 1): | |
| count_3 += 1 | |
| count_5 += 1 | |
| if count_3 == 3 and count_5 == 5: | |
| print('fizzbuzz') | |
| count_3 = count_5 = 0 | |
| elif count_3 == 3: | |
| print('fizz') | |
| count_3 = 0 | |
| elif count_5 == 5: | |
| print('buzz') | |
| count_5 = 0 | |
| else: | |
| print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment