public class FizzBuzz { public string GetOutput(int number) => number % 3 == 0 && number % 5 == 0 ? "FizzBuzz" : number % 3 == 0 ? "Fizz" : number % 5 == 0 ? "Buzz" : number.ToString(); }
- 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 string GetOutput(int number) =>
- number % 3 == 0 && number % 5 == 0 ? "FizzBuzz" : number % 3 == 0 ? "Fizz" : number % 5 == 0 ? "Buzz" : number.ToString();
- }
public class FizzBuzz { public string GetOutput(int number) { if (number % 15 == 0) return "FizzBuzz"; else if (number % 3 == 0) return "Fizz"; else if (number % 5 == 0) return "Buzz"; else return number.ToString(); // Fizz buzz is a popular computer science interview question. // The function above is given a number - if the number is // divisible by 3, return "fizz", if it's divisible by 5, // return "buzz", if not divisble by 3 or 5 - return the // number itself. } }
- public class FizzBuzz
- {
- public string GetOutput(int number) {
if (number % 15 == 0) {return "FizzBuzz";}else if (number % 3 == 0) {return "Fizz";}else if (number % 5 == 0) {return "Buzz";}else {return number.ToString();}- if (number % 15 == 0) return "FizzBuzz";
- else if (number % 3 == 0) return "Fizz";
- else if (number % 5 == 0) return "Buzz";
- else return number.ToString();
- // Fizz buzz is a popular computer science interview question.
- // The function above is given a number - if the number is
- // divisible by 3, return "fizz", if it's divisible by 5,
- // return "buzz", if not divisble by 3 or 5 - return the
- // number itself.
- }
- }