Created
November 6, 2019 16:44
-
-
Save RoastBeefKazenakis/519756e466c6a061e25cce446c97905c to your computer and use it in GitHub Desktop.
Thomas' fizzBuzz challenge submission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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