Easy 0 solved 0% acceptance

Fizz Buzz

Build a sequence using divisibility by 3 and 5.

Problem

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.

Constraints

0 ≤ limit ≤ 10,000. A limit of 0 produces an empty list.

Examples

Example 1
Input:
limit = 5

Expected output:
expected = ["1", "2", "Fizz", "4", "Buzz"]
Input:
long long limit = 5;

Expected output:
std::vector<std::string> expected = {"1", "2", "Fizz", "4", "Buzz"};
Input:
long limit = 5;

Expected output:
string[] expected = new string[] {"1", "2", "Fizz", "4", "Buzz"};

Explanation

3 is divisible by 3 and 5 is divisible by 5. Other entries keep their number.

Example 2
Input:
limit = 0

Expected output:
expected = []
Input:
long long limit = 0;

Expected output:
std::vector<std::string> expected = {};
Input:
long limit = 0;

Expected output:
string[] expected = new string[] {};

Explanation

There are no integers from 1 through 0, so the list is empty.

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.