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 let me know if you have any questions!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started