repl.it
@Koopolt/

fizz buzz

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
main.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
using System;

class MainClass {
  public static void Main (string[] args) {
    for (int i = 1; i <= 100; i++)
    {

      if (i % 3 == 0 && !(i % 5 == 0))
      {
        Console.WriteLine("Fizz");
      }
      if (i % 5 == 0 && !(i % 3 == 0))
      {
        Console.WriteLine("Buzz");
      }
      if (i % 3 == 0 && i % 5 == 0)
      {
        Console.WriteLine("Fizz - Buzz");
      }
      if (!(i % 5 == 0) && !(i % 3 == 0))
      {
        Console.WriteLine(i);
      }
    }
  }
}