March 11, 2020
Three Completely Different Approaches to the FizzBuzz Problem
Here’s a solution to the classic infamous FizzBuzz problem in Python:
for i in range(1, 31): if i % 15 == 0: print("FizzBuzz") elif i % 3 == 0: print("Fizz") elif i % 5 == 0: print("Buzz") else: print(i) 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz This program is really simple and is probably the most common approach.
Read more