Skip to content

Instantly share code, notes, and snippets.

View dkliman's full-sized avatar

Dave Kliman dkliman

View GitHub Profile
@dkliman
dkliman / FizzBuzz.swift
Last active July 1, 2017 01:45
Swift Coding Challenges Chapter 2, Challenge 16: Fizz Buzz
//Chapter 2: Numbers
//Challenge 16: Fizz Buzz
func fizzBuzz() {
for number in 1...100 {
let fizz = (number % 3 == 0) ? "Fizz " : ""
let buzz = (number % 5 == 0) ? "Buzz" : ""
let printableNumber = fizz + buzz == "" ? String(number) : ""
print ("\(printableNumber)\(fizz)\(buzz)")
}