public class FizzBuzz { public string GetOutput(int number) { if (number % 3 == 0 && number % 5 == 0) return "FizzBuzz"; if (number % 3 == 0) return "Fizz"; if (number % 5 == 0) return "Buzz"; return number.ToString(); } }
- public class FizzBuzz
- {
public string GetOutput(int number) {- public string GetOutput(int number)
- {
string str = "";if (number % 3 == 0 && number % 5 == 0){return "FizzBuzz";}if (number % 3 == 0){return "Fizz";}if (number % 5 == 0){return "Buzz";}if (str.Length == 0){str = number.ToString();}return str;- if (number % 3 == 0 && number % 5 == 0) return "FizzBuzz";
- if (number % 3 == 0) return "Fizz";
- if (number % 5 == 0) return "Buzz";
- return number.ToString();
- }
- }