Skip to content

Instantly share code, notes, and snippets.

@Krelborn
Created June 6, 2014 21:31
Show Gist options
  • Save Krelborn/be47dde25327ba9d68e0 to your computer and use it in GitHub Desktop.
Save Krelborn/be47dde25327ba9d68e0 to your computer and use it in GitHub Desktop.
My Swift implementation of FizzBuzz
for i in 1...100
{
var isDivisibleBy3 = ((i % 3) == 0)
var isDivisibleBy5 = ((i % 5) == 0)
if isDivisibleBy3 && isDivisibleBy5
{
println("FizzBuzz")
}
else if isDivisibleBy3
{
println("Fizz")
}
else if isDivisibleBy5
{
println("Buzz")
}
else
{
println("\(i)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment