The Fizzbuzz problem

May 12, 2009

You are given the following assignment:

You are to write a program that must fulfill these simple requirements:

For the numbers from 1 to 100,

  • If the number is a multiple of 3, print fizz instead of the number.
  • If the number is a multiple of 5, print buzz instead of the number.
  • If the number is a multiple of 15, print fizzbuzz instead of the number.
  • Otherwise, print the number itself.
  • Each output should be followed by a new line.

Can you code that and get it right in less than one minute? In less than two? How many retries will be necessary? Open your favorite editor for your favorite programming language. Ready? Set? Go!

Read the rest of this entry »


Follow

Get every new post delivered to your Inbox.

Join 41 other followers