I am trying to create a recursive function call method that would print the Fibonacci until a specific location:
1 function f = fibonacci(n)
2 fprintf(\'The
Create a function, which returns Integer:
func fibonacci(number n : Int) -> Int
{
guard n > 1 else {return n}
return fibonacci(number: n-1) + fibonacci(number: n-2)
}
This will return the fibonacci output of n numbers, To print the series You can use this function like this in swift:
for _ in 0...10
{
print(fibonacci(number : 10))
}
It will print the series of 10 numbers.