1 Write Recursive Method Fib Int N Takes Int N Returns Result Fibonacci S Nth Term F N F N Q37145794

1. Write a recursive method fib(intn) that takes in and int n and returnsthe result of fibonacci’s nth term

F(n) = F(n-1) + F(n-2) F(3) = F(2) + F(1) = 1 + 1 = 2F(2) = F(1) + F(0) = 1 + 0 = 1F(1) = 1 //base caseF(0) = 0 //base case

2. Write a recursive methodgetPowerOfXtoN(int xBase, int nExp) that takes in2 arguments, an int xBase (positive or negative),and a positive exponent int nExp. The method willuse recursion to calculate and return the result.

Xn

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.