Exercise 14: Recursion
Let's test your ability to use recursion.
We'll cover the following
Problem Statement
Implement a recursive function that takes a number as input, and output the term of the Fibonacci series.
The Fibonacci sequence is where the nth term is the sum of and term.
The term is and the term is . Therefore, the term is .
Input
A testVariable
that contains the term
Output
The term in the Fibonacci series, i.e., the element in the Fibonacci series at index testVariable
Sample Input
6
Sample Output
8
Test Yourself
Write your code in the given area. If you get stuck, you can look at the solution.
recursiveFibonacci <- function(testVariable){# Write your code here}