Skip to content

Instantly share code, notes, and snippets.

@EvolvingParty
Created November 13, 2022 23:03
Embed
What would you like to do?
100 Days of SwiftUI! DAY 6
import Cocoa
///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.
for i in 1...100 {
if i.isMultiple(of:3) && i.isMultiple(of:5) {
print("FizzBuzz")
} else if i.isMultiple(of:3) {
print("Fizz")
} else if i.isMultiple(of:5) {
print("Buzz")
} else {
print("\(i)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment