Jump to content

Programming Challenge: FizzBuzz with a Twist (Jan 13, 2025)

Featured Replies

Posted

Let's start with a classic!
I wanted to create a simple challenge for kids or beginners just starting out with programming. FizzBuzz is one of the most basic challenges you'll encounter, but it's also a great way to practice loops and conditions.

Hint: You can only % so much... after that, it’s all about $. 😉

Have fun coding, and don’t forget to share your twist on the solution!

Write a program that implements the classic FizzBuzz game with an additional twist:

Basic Requirements:

  1. For numbers from 1 to 100:

    • Print "Fizz" if the number is divisible by 3.

    • Print "Buzz" if the number is divisible by 5.

    • Print "FizzBuzz" if the number is divisible by both 3 and 5.

    • Print the number if none of the above conditions are met.

Bonus Twist Features:

  • Allow the user to input the range of numbers to check.

  • Add a new condition:

    • Print "Bazz" if the number is divisible by 7.

    • Combine outputs for numbers divisible by multiple conditions (e.g., 21 would print "FizzBazz").

Example Output:

Enter the starting number: 1
Enter the ending number: 50

1
2
Fizz
4
Buzz
Fizz
Bazz
8
Fizz
Buzz
11
Fizz
13
Bazz
FizzBuzz
  • Views 185
  • Created
  • Last Reply

Create an account or sign in to comment

Important Information

Terms of Use Privacy Policy Guidelines We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.