Strings
Data Types
Iterators
Control Flow
Object-oriented Programming
Basic Language Features
Fundamentals
Programming Paradigms
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 % 3 == 0 && number % 5 == 0) {- 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.
- }
- }