Menu
Coddy logo textTech

Game Overview

Part of the Fundamentals section of Coddy's Swift journey — lesson 58 of 86.

challenge icon

Challenge

Easy

In this chapter, you'll build a customizable FizzBuzz game step by step.

Read a single number from input and determine what to print based on the classic FizzBuzz rules:

  • If the number is divisible by both 3 and 5, print FizzBuzz
  • If the number is divisible by 3 only, print Fizz
  • If the number is divisible by 5 only, print Buzz
  • Otherwise, print the number itself

You will receive the following input:

  • A single integer

For example, if the input is 15, the output should be:

FizzBuzz

If the input is 9, the output should be:

Fizz

If the input is 7, the output should be:

7

Try it yourself

// Read input
let number = Int(readLine()!)!

// TODO: Write your code below to implement FizzBuzz logic
// Check divisibility by 3 and 5, then print the appropriate result

All lessons in Fundamentals