-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathFizzBuzz.cs
More file actions
36 lines (32 loc) · 1.05 KB
/
FizzBuzz.cs
File metadata and controls
36 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
namespace FizzBuzz
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
// This is FizzBuzz
// Count from 0 to 100
// If the the count number is divisble by 5 and 3 (15) without a remainder print "FizzBuzz"
// If the the count number is divisble by 5 without a remainder print "Buzz"
// If the the count number is divisble by 3 without a remainder print "Fizz"
// If none of the above apply, print out the number
for (int i = 1; i <= 100; i++)
{
if ( (i - ((i / 15) * 15)) == 0) {
Console.WriteLine("FizzBuzz");
}
else if ( (i - ((i / 5) * 5)) == 0) {
Console.WriteLine("Buzz");
}
else if ( (i - ((i / 3) * 3)) == 0) {
Console.WriteLine("Fizz");
}
else {
Console.WriteLine(i);
}
}
}
}
}