1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00

feat(solutions): add fizzbuzz/cs/function

This commit is contained in:
Divlo 2021-09-10 22:28:04 +02:00
parent 43fe49a5be
commit a1f20afb36
No known key found for this signature in database
GPG Key ID: 6F24DA54DA3967CF
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# fizzbuzz/cs/function
Created by [@Divlo](https://github.com/Divlo) on 10 September 2021.

View File

@ -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);
}
}
}
}
}