PIXELBANKv8.2.1
Menu

FizzBuzz Classic

Problem Statement

Implement the classic FizzBuzz algorithm.

Background

FizzBuzz is a common programming challenge:

  • Print "Fizz" for multiples of 3
  • Print "Buzz" for multiples of 5
  • Print "FizzBuzz" for multiples of both
  • Otherwise print the number

Your Task

Write a function fizzbuzz(n) that returns a list of FizzBuzz results from 1 to n.

Output Format

Return a list of strings.

Example:

Input:
n = 15
Output:
['1', '2', 'Fizz', '4', 'Buzz', 'Fizz', '7', '8', 'Fizz', 'Buzz', '11', 'Fizz', '13', '14', 'FizzBuzz']
Reasoning:

3,6,9,12 -> Fizz, 5,10 -> Buzz, 15 -> FizzBuzz

Constraints:

  • n >= 1
  • Check divisibility by both 3 and 5 first
Editor

Test Results

0/0
Run code to see test results.