問題
翻訳を表示For each integer from 1 through limit, use Fizz for multiples of 3, Buzz for multiples of 5, and FizzBuzz for multiples of both. Otherwise use the number written as text. Return the entries in order instead of printing them.
Implement fizz_buzz(limit).
Input
limit: The last integer to include.
Output
Return a list of strings, one for each integer from 1 through limit.
制約
0 ≤ limit ≤ 10,000. A limit of 0 produces an empty list.
例
入力:
limit = 5
期待される出力:
expected = ["1", "2", "Fizz", "4", "Buzz"]
入力:
long long limit = 5;
期待される出力:
std::vector<std::string> expected = {"1", "2", "Fizz", "4", "Buzz"};
入力:
long limit = 5;
期待される出力:
string[] expected = new string[] {"1", "2", "Fizz", "4", "Buzz"};
解説
3 is divisible by 3 and 5 is divisible by 5. Other entries keep their number.
入力:
limit = 0
期待される出力:
expected = []
入力:
long long limit = 0;
期待される出力:
std::vector<std::string> expected = {};
入力:
long limit = 0;
期待される出力:
string[] expected = new string[] {};
解説
There are no integers from 1 through 0, so the list is empty.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。