Department of Mathematics FAS Harvard University One Oxford Street Cambridge MA 02138 USA Tel: (617) 495-2171 Fax: (617) 495-5132
FAS Computer Services to Harvard University IT: (617) 495-7777.
Swift is programming language for iOS and OSX from Apple. Swift code works side-by-side with Objective-C. XCode is the IDE. While typing code, the compiler always gives feedback. This allows "swift programming".
Here is the Ulam (Collatz or 3n+1) game in Swift together with a screen shot during writing. Ulam.playground.tgz
// Ulam Game

for n in 1...20 {
    var k=n
    var s=0
    while k>1 {
        s++
        if k % 2 == 0 {
            k=k/2
        } else {
            k=3*k+1
        }
    }
    println(s)
}
println("end")





Simplicity, Clarity, Generality B.W. Kernighan, R. Pike, in "The Practice of Programming".
Privacy
HTML CSS