Skip to content

Instantly share code, notes, and snippets.

@mmloveaa
Last active December 29, 2017 09:29
Show Gist options
  • Save mmloveaa/71e69e4a6d3eb24a92923768374e4bc0 to your computer and use it in GitHub Desktop.
Save mmloveaa/71e69e4a6d3eb24a92923768374e4bc0 to your computer and use it in GitHub Desktop.
4-19 Q1
Complete the function fibonacci to return an array containing the first N Fibonacci numbers.
fib(n) = n , n <= 1
= fib(n-2) + fib(n-1), otherwise
Constraints:
1 ≤ N ≤ 10
Sample Input
4
Sample Output
0
1
1
2
Explanation
fib(0) = 0 by definition
fib(1) = 1
fib(2) = fib(0) + fib(1) = 0 + 1 = 1
fib(3) = fib(1) + fib(2) = 1 + 1 = 2
function fibonacci(n) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment