Skip to content

Instantly share code, notes, and snippets.

@pravj
Last active July 30, 2019 00:20
Show Gist options
  • Save pravj/e4af092f494bd46cddc9 to your computer and use it in GitHub Desktop.
Save pravj/e4af092f494bd46cddc9 to your computer and use it in GitHub Desktop.
99 Bottles of Beer in Swift Language
var i = 99
while i > 0
println(i + " bottles of beer on the wall, " + i + "bottles of beer.")
var num = i - 1
if i == 1 {
var num = "no more"
}
println("Take one down and pass it around, " + num + "bottles of beer on the wall.")
println("No more bottles of beer on the wall, no more bottles of beer.")
println("Go to the store and buy some more, 99 bottles of beer on the wall.")
@IOOI-SqAR
Copy link

Swift 5:

for i in (1...99).reversed() {
    print("\(i) bottles of beer on the wall, \(i) bottles of beer.")
    var num = String(i - 1)
    if ( i == 1 ) { num = "no" }
    print("Take one down and pass it around, \(num) bottles of beer on the wall.")
}
print("No more bottles of beer on the wall, no more bottles of beer.")
print("Go to the store and buy some more, 99 bottles of beer on the wall.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment