Skip to content

Instantly share code, notes, and snippets.

@RoastBeefKazenakis
Created November 6, 2019 16:44
Show Gist options
  • Save RoastBeefKazenakis/519756e466c6a061e25cce446c97905c to your computer and use it in GitHub Desktop.
Save RoastBeefKazenakis/519756e466c6a061e25cce446c97905c to your computer and use it in GitHub Desktop.
Thomas' fizzBuzz challenge submission
func fizzBuzz(_ n: Int) -> [String] {
var results: [String] = []
for num in 1...n {
if num % 3 == 0, num % 5 == 0 {
results.append("fizzBuzz")
} else if num % 3 == 0, num % 5 != 0 {
results.append("fizz")
} else if num % 5 == 0, num % 3 != 0 {
results.append("Buzz")
} else {
results.append("\(num)")
}
}
return results }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment