Skip to content

Instantly share code, notes, and snippets.

@billdozr
Created May 30, 2011 09:19
Show Gist options
  • Save billdozr/998642 to your computer and use it in GitHub Desktop.
Save billdozr/998642 to your computer and use it in GitHub Desktop.
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Ham" instead of the number and for the multiples of five print "Jam". For numbers which are multiples of both three and five print "HamJam".
@mjallday
Copy link

must. concentrate. on. work.

for i in range(101):
    if i > 0 and i % 3 == 0 and i % 5 == 0:
        print('HamJam')
    elif i > 0 and i % 3 == 0:
        print('Ham')
    elif i > 0 and i % 5 == 0:
        print('Jam')
    else:
        print(i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment