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

다른 사람의 풀이 보기

커뮤니티 솔루션

아직 공개된 풀이가 없습니다. 문제를 풀고 첫 풀이를 공유하세요.