Question: In this lab we will write two recursive methods: one will calculate the sum of the first k numbers squared and the other will calculate

In this lab we will write two recursive methods: one will calculate the sum of the first k numbers squared and the other will calculate the nth term of the Fibonacci sequence. Both methods should be written in the Recursion class as static methods. Both methods should be written using recursion, not iteration. You should test each method by adding several calls to these methods in the main method of the RecursionDriver class and then printing out the results. The first static method should be called sumOfSquares. This method should have one parameter called k of type int. It should return the sum of the squares of the numbers up to and including k (i.e. it should return 1*1 + 2*2 + ... +k*k). The second static method should be called fib. It should have one parameter called n of type int. It should return the nth term of the Fibonacci sequence. The Fibonacci sequence is defined as: 1, 1, 2, 3, 5, 8, 13, 21... where the next term is equal to the previous two terms added together
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
