Navigation

Search

Categories

On this page

FizzBuzz

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Wednesday, April 18, 2007
Wednesday, April 18, 2007 9:05:04 AM (Mountain Daylight Time, UTC-06:00) ( )

Fizz, Buzz

for (int i = 1; i <= 100; i++) // Count from 1 to 100
{
  Console.WriteLine(
    String.Format("{0,3:d} {1}{2}",
    i, // Display the number
    (bool)(i%3!=0) ? "":"Fizz", // Display Fizz if divisible by 3
    (bool)(i%5!=0) ? "":"Buzz") // Display Buzz if divisible by 5
  );
}

Comments [0] | | #