Skip to content

Instantly share code, notes, and snippets.

@Manasseh919
Created January 4, 2021 15:11
Show Gist options
  • Save Manasseh919/93123c557d8ca8fba83262c77fc715dc to your computer and use it in GitHub Desktop.
Save Manasseh919/93123c557d8ca8fba83262c77fc715dc to your computer and use it in GitHub Desktop.
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
using System;
namespace Fizz_Buzz
{
class Program
{
static void Main(string[] args)
{
int n = 100;
for(int i = 1;i<=n;i++)
{
if(i%3== 0)
{
Console.WriteLine("Fizz");
}
else if(i%5 == 0)
{
Console.WriteLine("Buzz");
}
else if (i % 15 == 0)
{
Console.WriteLine("FizzBuzz");
}
else
{
Console.WriteLine(i);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment