I tried to finish in one line
public class FizzBuzz { public string GetOutput(int number) => number % 15 == 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 string GetOutput(int number)
- => number % 15 == 0 ? "FizzBuzz" : number % 3 == 0 ? "Fizz" : number % 5 == 0 ? "Buzz" : number.ToString();
- }