Junior — Senior
Calculating the n‑th element of the modified Fibonacci sequence: recursive and iterative approaches
livecode
Task condition
Implement a function that returns the n-th member of the Fibonacci sequence, where the first two values are given as 10 and 20. You need to write two versions: one using recursion, and the other using a loop. The function takes the element number (for example, k) and returns its value.
Example 1: Input: k = 1 Output: 10
Example 2: Input: k = 4 Output: 50