public class FizzBuzz { 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; } }
- public class FizzBuzz
- {
- public string GetOutput(int number) {
for (int i = 1; i <= 100; i++){- string str = "";
if (i % 3 == 0)- if (number % 3 == 0 && number % 5 == 0)
- {
- return "FizzBuzz";
- }
- if (number % 3 == 0)
- {
str += "Fizz";- return "Fizz";
- }
if (i % 5 == 0)- if (number % 5 == 0)
- {
str += "Buzz";- return "Buzz";
- }
- if (str.Length == 0)
- {
str = i.ToString();- str = number.ToString();
- }
Console.WriteLine(str);}return "0";- return str;
- }
- }