Skip to content

Instantly share code, notes, and snippets.

@garethjwilliams
Created October 28, 2013 18:33
Show Gist options
  • Select an option

  • Save garethjwilliams/7202128 to your computer and use it in GitHub Desktop.

Select an option

Save garethjwilliams/7202128 to your computer and use it in GitHub Desktop.
Naive Python fizzbuzz with no divide or modulo.
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