home

Scientific Computing (Psychology 9040a)

Fall, 2020

Fizz Buzz


Write a short program that prints each number from 1 to 100 on a new line.

For each multiple of 3, print “Fizz” instead of the number.

For each multiple of 5, print “Buzz” instead of the number.

For numbers which are multiples of both 3 and 5, print “Fizz Buzz” instead of the number.

It should produce output like this:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
Fizz Buzz
16
...

A sample solution: fizzbuzz_sol