-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathfizzbuzz.cs
More file actions
28 lines (25 loc) · 825 Bytes
/
Copy pathfizzbuzz.cs
File metadata and controls
28 lines (25 loc) · 825 Bytes
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
using System;
using System.Linq;
namespace fizzbuzz
{
class Program
{
static void Main(string[] args)
{
Enumerable.Range(1, 100)
.Select(x => {
var divBy3 = x % 3 == 0;
var divBy5 = x % 5 == 0;
if (divBy3 && divBy5)
return "FizzBuzz";
else if (divBy3)
return "Fizz";
else if (divBy5)
return "Buzz";
return x.ToString();
})
.ToList()
.ForEach(Console.WriteLine);
}
}
}