Fundamentals
Strings
Data Types
Logic
public class FizzBuzz { public string GetOutput(int number) { bool fizz = number % 3 == 0; bool buzz = number % 5 == 0; return fizz && buzz ? "FizzBuzz" : fizz ? "Fizz" : buzz ? "Buzz" : number.ToString(); } }
- public class FizzBuzz
- {
- public string GetOutput(int number)
- {
if ((number % 3 == 0) && (number % 5 == 0))return "FizzBuzz";else if (number % 3 == 0)return "Fizz";else if (number % 5 == 0)return "Buzz";else return number.ToString();- bool fizz = number % 3 == 0;
- bool buzz = number % 5 == 0;
- return fizz && buzz ? "FizzBuzz" : fizz ? "Fizz" : buzz ? "Buzz" : number.ToString();
- }
- }