Skip to content

Instantly share code, notes, and snippets.

@henry0312
Created June 8, 2014 15:35
Show Gist options
  • Save henry0312/f3e84915e770a47e9b94 to your computer and use it in GitHub Desktop.
Save henry0312/f3e84915e770a47e9b94 to your computer and use it in GitHub Desktop.
FizzBuzz with Swift
func FizzBuzz(n: Int) {
for i in 1...n {
if i % 15 == 0 {
println("FizzBuzz")
} else if i % 3 == 0 {
println("Fizz")
} else if i % 5 == 0 {
println("Buzz")
} else {
println(i)
}
}
}
if C_ARGC != 2 {
println("Wrong arguments")
println("Usage: ./fizzbuzz Num")
} else {
FizzBuzz( String.fromCString(C_ARGV[1]).toInt()! )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment