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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!