Algorithms

FizzBuzz

easyalgorithmsloopsmodulo
0:00

Problem

Return an array containing strings from 1 to `n`. For multiples of 3 use "Fizz", for multiples of 5 use "Buzz", for multiples of both use "FizzBuzz". Otherwise, use the number as a string.

Your solution
Test results
Click Run tests to check your solution against the test cases.

About this challenge

FizzBuzz is a easy algorithms coding challenge. It tests algorithmic thinking and complexity analysis — the kind of problem-solving that shows up constantly in technical interviews. Write your solution in the editor above, run it against the test cases, and get instant feedback — free, in your browser, no sign-up.

Show a hint & approach (spoiler)

Hint: Check divisibility by 15 first (or equivalently both 3 and 5), then 3, then 5, then fall through to the number.

Keep practicing

Browse all coding challenges, or build intuition for the underlying concepts with the algorithm visualizers and the developer cheatsheets.