Last active
February 10, 2017 02:39
-
-
Save gjones/bd623fad47f315270a4a to your computer and use it in GitHub Desktop.
Simple solution to the Fizzbuzz question in Swift.
This file contains hidden or 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
// Write a program that prints the numbers from 1 to 100. | |
// For multiples of three print "Fizz" instead of the number | |
// For multiples of five print "Buzz". For numbers which | |
// For multiples of both three and five print "FizzBuzz". | |
for number in 1...100 { | |
if (number % 15 == 0) { | |
println("FizzBuzz") | |
} | |
else if (number % 3 == 0) { | |
println("Fizz") | |
} | |
else if (number % 5 == 0) { | |
println("Buzz") | |
} | |
else { | |
println(number) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment