Условие
Показать перевод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. Следуйте условию и ограничениям выше.