Here's the solution:
function fizzBuzz(n)
result := empty array
for i from 1 to n
if i mod 15 = 0 then
append "FizzBuzz" to result
else if i mod 3 = 0 then
append "Fizz" to result
else if i mod 5 = 0 then
append "Buzz" to result
else
append string representation of i to result
return result
Notice is the same as checking both and , because . This simplifies the condition.