Skip to content

Instantly share code, notes, and snippets.

@benyou1969
Created October 18, 2020 23:15
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 benyou1969/1491aebc0d0266580719991c469413c6 to your computer and use it in GitHub Desktop.
Save benyou1969/1491aebc0d0266580719991c469413c6 to your computer and use it in GitHub Desktop.
Swift Language - FizzBuzz
import Cocoa
let numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
var oneThousandNumbers = [Int]()
for i in 1...1000{
oneThousandNumbers.append(i)
}
for num in oneThousandNumbers {
if num % 15 == 0{
print("\(num) FizzBuzz")
}
else if num % 3 == 0{
print("\(num) Fizz")
}else if num % 5 == 0{
print("\(num) Buzz")
}else{
print(num)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment