Skip to content

Instantly share code, notes, and snippets.

@masters3d
Forked from dstaley/fizzbuzz.swift
Last active August 29, 2015 14:14
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 masters3d/ea46978ad769fc82e25f to your computer and use it in GitHub Desktop.
Save masters3d/ea46978ad769fc82e25f to your computer and use it in GitHub Desktop.
func fizzbuzz(i: Int) -> String {
let result = (i % 3, i % 5)
switch result {
case (0, _):
return "Fizz"
case (_, 0):
return "Buzz"
case (0, 0):
return "FizzBuzz"
default:
return "\(i)"
}
}
for number in 1...100 {
println(fizzbuzz(number))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment