Skip to content

Latest commit

 

History

History
14 lines (9 loc) · 806 Bytes

File metadata and controls

14 lines (9 loc) · 806 Bytes

Fibonacci(n) - recursive

Implement a recursive function, that takes in a number and returns an array containing the fibonacci numbers until the n-th. Start the sequence with 0.

  • The Fibonacci sequence is a set of numbers that starts with a one or a zero, followed by a one, and proceeds based on the rule that each number (called a Fibonacci number) is equal to the sum of the preceding two numbers.
  • A function is recursive, when it's defined in terms of itself.

Example:

Fibonacci(7) // returns [0,1,1,2,3,5,8]

Tips & Tricks

  • It doesn't make the outer function recursive, if you define and/or call another recursive function inside.
  • Returning these in an array makes it somewhat harder, you should fiddle around with different approaches