Created
June 6, 2014 21:31
-
-
Save Krelborn/be47dde25327ba9d68e0 to your computer and use it in GitHub Desktop.
My Swift implementation of FizzBuzz
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
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