From a1f20afb36a911abd6fe5326b4c7526ebb57726e Mon Sep 17 00:00:00 2001 From: Divlo Date: Fri, 10 Sep 2021 22:28:04 +0200 Subject: [PATCH] feat(solutions): add `fizzbuzz/cs/function` --- .../fizzbuzz/solutions/cs/function/README.md | 3 ++ .../solutions/cs/function/Solution.cs | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 challenges/fizzbuzz/solutions/cs/function/README.md create mode 100644 challenges/fizzbuzz/solutions/cs/function/Solution.cs diff --git a/challenges/fizzbuzz/solutions/cs/function/README.md b/challenges/fizzbuzz/solutions/cs/function/README.md new file mode 100644 index 0000000..b595104 --- /dev/null +++ b/challenges/fizzbuzz/solutions/cs/function/README.md @@ -0,0 +1,3 @@ +# fizzbuzz/cs/function + +Created by [@Divlo](https://github.com/Divlo) on 10 September 2021. diff --git a/challenges/fizzbuzz/solutions/cs/function/Solution.cs b/challenges/fizzbuzz/solutions/cs/function/Solution.cs new file mode 100644 index 0000000..a097bcb --- /dev/null +++ b/challenges/fizzbuzz/solutions/cs/function/Solution.cs @@ -0,0 +1,33 @@ +using System; + +namespace Solution +{ + class Program + { + static void Main() + { + int total = int.Parse(Console.ReadLine()); + for (int number = 1; number <= total; number++) + { + bool isDivisibleBy3 = number % 3 == 0; + bool isDivisibleBy5 = number % 5 == 0; + if (isDivisibleBy3 && isDivisibleBy5) + { + Console.WriteLine("FizzBuzz"); + } + else if (isDivisibleBy3) + { + Console.WriteLine("Fizz"); + } + else if (isDivisibleBy5) + { + Console.WriteLine("Buzz"); + } + else + { + Console.WriteLine(number); + } + } + } + } +}