Created
September 21, 2015 05:08
-
-
Save enomoto/a1563aedffd6401d3f71 to your computer and use it in GitHub Desktop.
FizzBuzz in Swift
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(num: Int) -> String { | |
switch num { | |
case _ where num % 15 == 0: | |
return "FizzBuzz" | |
case _ where num % 3 == 0: | |
return "Fizz" | |
case _ where num % 5 == 0: | |
return "Buzz" | |
default: | |
return num.description | |
} | |
} | |
for num in 0...20 { | |
print(fizzBuzz(num)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment