Problem 229. Fizz Buzz
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'
Solution Stats
Problem Comments
-
2 Comments
Matthew Eicholtz
on 5 Jul 2013
I would suggest trying not to give away a solution within the test suite.
bainhome
on 5 May 2015
wouldn't be better to remove TestSuite's case6:the empty matrix? it make arrayfun more suitable.
Solution Comments
Show commentsProblem Recent Solvers112
Suggested Problems
-
It dseon't mettar waht oedrr the lrettes in a wrod are.
2074 Solvers
-
1616 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
554 Solvers
-
746 Solvers
-
Calculate the height of an object dropped from the sky
280 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!