आसान 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 के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।

दूसरों से सीखें

समुदाय समाधान

अभी तक कोई प्रकाशित समाधान नहीं। पहला साझा करने के लिए इस चुनौती को हल करें।