-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFizzBuzz.cs
48 lines (42 loc) · 1.24 KB
/
FizzBuzz.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
/*
In the above code, we use a for loop to iterate from 1 to 100. We then check if
each number in the loop is divisible by 3 and/or 5, and print "Fizz" for numbers
divisible by 3, "Buzz" for numbers divisible by 5, "FizzBuzz" for numbers divisible
by both 3 and 5, and the number itself for all other cases.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FiveDaysTrainings
{
internal class FizzBuzz
{
public void fizz_buzz()
{
Console.WriteLine("\nFIZZ BUZZ");
int item = 89;
for(int a = item; a <= 100; a++)
{
if(a % 3 == 0 && a % 5 == 0)
{
Console.WriteLine("FIZZBUZZ");
}
else if (a % 5 == 0)
{
Console.WriteLine("FIZZ");
}
else if (a % 3 == 0)
{
Console.WriteLine("BUZZ");
}
else
{
Console.WriteLine(item);
}
}
Console.WriteLine("--------------------------------");
}
}
}