Created
October 18, 2020 23:15
-
-
Save benyou1969/1491aebc0d0266580719991c469413c6 to your computer and use it in GitHub Desktop.
Swift Language - 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
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