Skip to content

Instantly share code, notes, and snippets.

Created September 3, 2015 00:20
Show Gist options
  • Save anonymous/519986ea8025fecae991 to your computer and use it in GitHub Desktop.
Save anonymous/519986ea8025fecae991 to your computer and use it in GitHub Desktop.

This is a problem from the Recourse Center's application: https://www.recurse.com/apply

Write a program that prints out the numbers 1 to 100 (inclusive). If the number is divisible by 3, print Crackle instead of the number. If it's divisible by 5, print Pop. If it's divisible by both 3 and 5, print CracklePop. You can use any language.

from __future__ import print_function #future proofing
def isDivisible(number, divisor):
return number % divisor == 0 # check if the residual from division is zero
for i in range(1,101):
output = ""
if isDivisible(i, 3):
output += "Crackle"
if isDivisible(i, 5):
output += "Pop"
print(i if output == "" else output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment