/* FIZZ BUZZ
Your goal is to loop from 1 through 100, and for each number:
If it’s a multiple of 3, print “Fizz”
If it’s a multiple of 5, print “Buzz”
If it’s a multiple of 3 and 5, print “FizzBuzz”
Otherwise, just print the number.
*/
import UIKit
let fizz = 3
let buzz = 5
for i in 1...100
{
if i % 3 == 0 && i % 5 == 0 {
print("FizzBuzz")
}
else if i % 3 == 0 {
print("Fizz")
}
else if i % 5 == 0 {
print("Buzz")
}
else {
print(i)
}
}
No comments:
Post a Comment