MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Given an array of positive, non-zero, integers, return a cell array of strings the same size as the input, where each element in the output contains:

`'fizz'`if the corresponding input is a multiple of 3`'buzz'`if the corresponding input is a multiple of 5`'fizzbuzz'`if the corresponding input is a multiple of 15- the string representation of the number otherwise.

Example:

>> out = fizzbuzz(1) out = '1'

>> out = fizzbuzz(1:5) out = '1' '2' 'fizz' '4' 'buzz'

>> out = fizzbuzz([3 5 15]) out = 'fizz' 'buzz' 'fizzbuzz'

71 correct solutions
121 incorrect solutions

Last solution submitted on Jun 10, 2015

1 Comment

Vincent
on 9 Feb 2012

The problem description is a little misleading in stating that the input will contain positive, non-zero integers. Why include an empty array in the test suite?

2 Comments