Write a C# function "FizzBuzz", the function takes in an integer as a parameter and…
- User
Write a C# function "FizzBuzz", the function takes in an integer as a parameter and returns a string.
Assistant
Here is a C# function FizzBuzz that takes an integer and returns a string:
string FizzBuzz(int n) { if (n % 3 == 0 && n % 5 == 0) return "FizzBuzz"; if (n % 3 == 0) return "Fizz"; if (n % 5 == 0) return "Buzz"; return n.ToString(); }This function checks the following:
- If the number is divisible by 3 and 5, return "FizzBuzz"
- If the number is divisible by 3, return "Fizz"
- If the number is divisible by 5, return "Buzz"
- Otherwise just return the number as a string
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.