At a job interview the other day i came across the fizz buzz test in the wild for the first time. Simple little thing but seems to floor people.
In case you have not seen it you output the numbers 1 to 100 but replace those divisible by 3 with “Fizz” and those divisible by 5 with “Buzz”.
The real trick is less in the programming than in an easy way to determine the div by 3 & 5 and here the trick is to remember your modulo arithmetic.
So simply put i = 1 to 100
if i%3 == 0 print Fizz
if i%5 == 0 print Buzz
else print i