Created
June 19, 2023 19:17
-
-
Save yasinnaal/7711780b62df8757c994847318717498 to your computer and use it in GitHub Desktop.
fizzbuzz challenge Python snippets
This file contains 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
# 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