문제
번역본 보기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에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.