Skip to content

Instantly share code, notes, and snippets.

@EvolvingParty
Created November 13, 2022 23:03
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 EvolvingParty/b2d4fb433d7a25cff09ec330905cd08a to your computer and use it in GitHub Desktop.
Save EvolvingParty/b2d4fb433d7a25cff09ec330905cd08a to your computer and use it in GitHub Desktop.
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