Write me a simple python program that implements fizz buzz
- User
Write me a simple python program that implements fizz buzz
- Assistant
Sure, here's a Python program that implements the FizzBuzz problem:
def fizzbuzz(n): if n == 0: return "0" elif n == 1: return "1" elif n == 2: return "2" elif n % 3 == 0 and n % 5 == 0: return fizzbuzz(n // 3) + fizzbuzz(n // 5) elif n % 3 == 0: return fizzbuzz(n // 3) elif n % 5 == 0: return fizzbuzz(n // 5) else: return str(n) n = int(input("Enter a number: ")) print(fizzbuzz(n))This program takes a number
nas input, and then checks if it's divisible by 3 and 5. If it is, it returns a concatenation of the two FizzBuzz numbers for that value ofn. If is not divisible by 3 or 5, it returns the corresponding number.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.