Swift - Write program to print out the Fibonacci sequence

Requirements

Write program to print out the Fibonacci sequence

Hint

The Fibonacci numbers is a series of numbers in the following sequence:

1,1,2,3,5,8,13,21,34,55,89,144,...

Demo

func Fibonacci(num:Int) -> Int {
    if num <= 1 {
        return 1/*from  w  ww  . j  a v  a2  s . c  o m*/
    }
    return Fibonacci(num - 1) + Fibonacci(num - 2)
}

//prints out the first 13 Fibonacci numbers---
for i in 0...12 {
    print(Fibonacci(i))
}

Related Exercise