-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfizzbuzz.cs
47 lines (39 loc) · 869 Bytes
/
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
using System;
namespace Application
{
public class fizzbuzz
{
public fizzbuzz ()
{
for(int a = 1; a < 100; a++){
Console.WriteLine(fizz_or_buzz(a));
}
}
public string fizz_or_buzz (int number)
{
string fizz_or_buzz_string;
if ( (number_modulo(number, 3)) && (number_modulo(number, 5)) ) {
fizz_or_buzz_string = "FizzBuzz";
} else if (number_modulo(number, 3)) {
fizz_or_buzz_string = "Fizz";
} else if (number_modulo(number, 5)) {
fizz_or_buzz_string = "Buzz";
} else {
fizz_or_buzz_string = number.ToString();
}
return fizz_or_buzz_string+"\n";
}
public Boolean number_modulo (int number, int dividend){
if ((number % dividend) == 0) {
return true;
} else {
return false;
}
}
}
public class test {
public static void Main(){
fizzbuzz f = new fizzbuzz();
}
}
}