1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz

FizzBuzz is a toy problem used in programming job interviews. This gem solves this problem for you so you can get right back to your interview....

Usage:

require 'rubygems'
require 'fizzbuzz'
puts fizzbuzz

The fundamental problem of FizzBuzz is to output a list from 1 to 100, one per line, with the following exceptions: numbers divisible by 3 should display "Fizz" instead of the number. Numbers divisible by 5 should display "Buzz" instead of the number. Numbers divisible by both 3 and 5 should display "FizzBuzz" instead of the number.

Contributors to the project are welcome to add their own algorithms for producing this list. After all, it is the development of these algorithms that are the purpose of the FizzBuzz problem.

See the list of authors (so far)

In order to provide maximum reuse, all solutions should return a list of the numbers and/or strings such that displaying them with puts will output them.

How to Get FizzBuzz

The easiest way is to simply install the gem:

sudo gem install fizzbuzz

Since the point of FizzBuzz is to be outrageous and overthought and generally as insouciant as possible, there is no stable version. The gem, however, may not be as full of up-to-the-minute interestingness as the svn repository. To address this critical failing, you must check out the latest version of the code directly from SVN:

svn co svn://rubyforge.org/var/svn/fizzbuzz/trunk fizzbuzz

Note that with the gem, your mileage will vary. With the svn repository, it your mileage will vary more.

Continue on to the project