By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Complete the code challenge below. Read the instructions carefully and use the integrated editor on the right to write and run your solution.
FizzBuzz is a straightforward problem that appears constantly in programming interviews. You need to write code that processes numbers 1 through 100 and outputs them with specific replacements based on divisibility rules. It's deceptively simple, but getting it right teaches you about modulo arithmetic and the importance of condition ordering.
Here's what your code needs to do for each number:
The critical detail here is that you must check for divisibility by both 3 and 5 before checking either condition individually. If you check divisibility by 3 first and output "Fizz", you'll never get to check if it's also divisible by 5.
The % operator gives you the remainder. 15 % 3 == 0 and 15 % 5 == 0.
Use the modulo operator (%) to check divisibility. When a number is evenly divisible, the remainder is zero. So to check if a number is divisible by 3, use number % 3 == 0. This is the core technique you'll need.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.