Skip to content

Instantly share code, notes, and snippets.

@jollyjoester
Created April 15, 2017 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jollyjoester/601e5ce50f9697dfdcdfbd74c0b0706d to your computer and use it in GitHub Desktop.
Save jollyjoester/601e5ce50f9697dfdcdfbd74c0b0706d to your computer and use it in GitHub Desktop.
fizzbuzz in Swift
(1...100).map {
switch ($0 % 3, $0 % 5) {
case (0, 0): return "Fizz Buzz"
case (0, _): return "Fizz"
case (_, 0): return "Buzz"
case (_, _): return "\($0)"
}
}.forEach { print($0) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment