簡単 0件解決済み 正答率0%

Fizz Buzz

Build a sequence using divisibility by 3 and 5.

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.

例

例 1
入力:
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.

例 2
入力:
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用に調整されています。上記の説明と制約に従ってください。

他の人の解答から学ぶ

コミュニティの解答

まだ公開された解答がありません。この課題を解いて最初の解答を共有しましょう。