Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Fizz Buzz/FizzBuzz.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
// Last checked with Xcode Version 11.4.1 (11E503a)


/**
* This function takes in an integer numberOfTurns as an input and prints out the numbers from 1 to numberOfTurns with the following modification:
* - If the number is divisible by 3, it prints "Fizz" instead of the number
* - If the number is divisible by 5, it prints "Buzz" instead of the number
* - If the number is divisible by both 3 and 5, it prints "Fizz Buzz" instead of the number
* - If the numberOfTurns is less than 1, it will print "Number of turns must be >= 1"
*
* - parameter numberOfTurns: the number of turns for the fizzbuzz game
*/


func fizzBuzz(_ numberOfTurns: Int) {
guard numberOfTurns >= 1 else {
print("Number of turns must be >= 1")
Expand All @@ -18,4 +30,4 @@ func fizzBuzz(_ numberOfTurns: Int) {
print("Fizz Buzz")
}
}
}
}