Question: Week #4- Recursion -Create a class called Week4Main, in package week4, with a main method. Add methods harmonicI, harmonicR, and lucasR to the Week4Main class

Week #4- Recursion

-Create a class called Week4Main, in package week4, with a main method.

Add methods harmonicI, harmonicR, and lucasR to the Week4Main class as described in these sections:

A

-Define Hn=11+12+13+14++1n - these are referred to as the harmonic numbers.

-Write a private static double method in Week4Main called harmonicI which is iterative, that takes in integer n as input, and returns Hn . -Write a private static double method in Week4Main called harmonicR which is recursive , that takes in integer n as input, that returns Hn .

B

-The Lucas numbers are a sequence of integers, named after douard Lucas, which are closely related to the Fibonacci sequence. In fact, they are defined in very much the same way: Ln=2if n=0;1if n=1;Ln-1+Ln-2if n>1

-Using the recursive description above, write a private static int method in Week4Main called lucasR which takes one parameter, n, and computes the nth Lucas number Ln.

Requirements/Constraints/Hints:

The code in the public static void main method for Week4Main will not be tested or counted as part of your grade, but you may use it yourself for testing.

For my JAVA PROGRAMMING ll class please answer accordingly

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!