412. Fizz Buzz
题目大意:给定一个n,输出一个1到n的数组,但是遇到3的倍数,则用“Fizz”代替,遇到5的倍数,则用“Buzz”代替,同时是3和5的倍数,则用“FizzBuzz”代替,例如输入:15,返回数组:["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
412. Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.For numbers which are multiples of both three and five output “FizzBuzz”.
Example:
n = 15,
Return:["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
Last updated
Was this helpful?