Skip to content

Instantly share code, notes, and snippets.

@yasinnaal
Created June 19, 2023 19:17
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 yasinnaal/7711780b62df8757c994847318717498 to your computer and use it in GitHub Desktop.
Save yasinnaal/7711780b62df8757c994847318717498 to your computer and use it in GitHub Desktop.
fizzbuzz challenge Python snippets
# fizzbuzz challenge
"""
The "Fizz-Buzz test" is an interview question designed to help
filter out the 99.5% of programming job candidates
Write a program that prints the numbers from 1 to 100.
But for multiples of three print “Fizz” instead of the number
and for the multiples of five print “Buzz”.
For numbers which are multiples of both three and five print “FizzBuzz”."
"""
n = 1
while n <= 100:
if n % 3 == 0 and n % 5 == 0:
print("FizzBuzz")
elif n % 3 == 0:
print("Fiz")
elif n % 5 == 0:
print("Buzz")
else:
print(n)
n += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment