Problem 1200. FizzBuzz
The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment is as follows:
"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."
Input: filename
Output: Create the FizzBuzz file
Expected Output:
1 2 Fizz 4 Buzz ...
The FizzBuzz site has the Matlab solution as:
for inum = 1:100 fizzbuzz = ''; if mod(inum,3) == 0 fizzbuzz = [fizzbuzz 'Fizz']; end if mod(inum,5) == 0 fizzbuzz = [fizzbuzz 'Buzz']; end if isempty(fizzbuzz) disp(inum) else disp(fizzbuzz) end end
Solution Stats
Problem Comments
-
1 Comment
Richard Zapor
on 13 Jan 2013
Reminder: The "output" is the written file. The function output is not used.
Solution Comments
Show commentsProblem Recent Solvers36
Suggested Problems
-
It dseon't mettar waht oedrr the lrettes in a wrod are.
1897 Solvers
-
Omit columns averages from a matrix
592 Solvers
-
Flip the main diagonal of a matrix
828 Solvers
-
How many monitors are connected ?
153 Solvers
-
Create a Multiplication table matrix...
568 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!