-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFizzBuzzTDD.cs
43 lines (39 loc) · 1.07 KB
/
FizzBuzzTDD.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
using System.Collections.Generic;
namespace Katas
{
public class FizzBuzzTDD
{
/**
Escribe un programa que imprima los números del 1 al 100,
pero aplicando las siguientes normas:
Devuelve Fizz si el número es divisible por 3.
Devuelve Buzz si el número es divisible por 5.
Devuelve FizzBuzz si el número es divisible por 3 y por 5.
*/
public static object ShowNumber(int n)
{
if (n%3==0 && n%5==0)
{
return "FizzBuzz";
}
if (n%3==0)
{
return "Fizz";
}
if (n%5==0)
{
return "Buzz";
}
return n;
}
public static List<object> FizzBuzz()
{
List<object> list = new List<object>();
for(int i = 1; i <= 100; i++)
{
list.Add(ShowNumber(i));
}
return list;
}
}
}