Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. public static void FizzBuzz()
  2. {
  3.     int count3 = 1;
  4.     int count5 = 1;
  5.     bool printed = false;
  6.  
  7.     for (var i = 1; i <= 100; i++)
  8.     {
  9.         printed = false;
  10.  
  11.         if (count3 == 3)
  12.         {
  13.             Console.Write("Fizz");
  14.             printed = true;
  15.             count3 = 0;
  16.         }
  17.         if (count5 == 5)
  18.         {
  19.             Console.Write("Buzz");
  20.             printed = true;
  21.             count5 = 0;
  22.         }
  23.         if (!printed)
  24.         {
  25.             Console.Write(i);
  26.         }
  27.         Console.WriteLine();
  28.         count3++;
  29.         count5++;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement