Fibonacci code challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Fibonacci code challenge

What is the output of the following code? func fib(n: Int) -> Int { return n < 2 ? N :(fib(n-1) + (fib(n-2)) } print(fib(3))

20th Nov 2017, 3:19 AM
Solomon Reese
Solomon Reese - avatar
1 Answer
+ 2
The output should be 2.
20th Nov 2017, 4:21 AM
Halla