Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1: Crazy series (50 points) In this session, you need to implement the crazy series method. In the crazy series, you will be given
Question 1: Crazy series (50 points) In this session, you need to implement the crazy series method. In the crazy series, you will be given a starting number. Then, you need to times 2 for each number until the number is greater than 100 . After the number is greater than 100 , you need to divide 3 until we reach the number is less than 5 . Note that the input number must be greater than 0 , and you are not allowed to use loop here. For example, crazySeries(10)shouldreturnArrayList[10.0,20.0,40.0,80.0,160.0,53.333333333333336,17.77777777777778,5.9259259259259265,1.9753086419753088]crazySeries(5)shouldreturnArrayList[5.0,10.0,20.0,40.0,80.0,160.0,53.333333333333336,17.77777777777778,5.9259259259259265,1.9753086419753088]crazySeries(1)shouldreturnArrayList[1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,42.666666666666664,14.22222222222221,4.7407407407407405] Question 2: Ben number (50 points) Ben had difficulty coming out with an assignment question, then he created an odd number called Ben number, which is the sum of a Ben series. Let x be the starting number and y be the bout number, in the Ben series, the x should double the value when it is an even number. In contrast, the number should be subtracted by 1 when x is an odd number. Both x and y should be greater than 0 . Example of a Ben series, Assume the x=3, and y=5, then the series should be [3,2,4,8,16]. Then the Ben number should be 33 because of 3+2+4+18+16. Thus, given the method benNumber (m,n), for all m,n>0 benNumber (2,5) should return 62 because 2+4+8+16+32=62 benNumber (3,8) should return 257 because 3+2+4+8+16+32+64+128=257 benNumber (1,1) should return 1 Note that you can only use recursion to solve Q1 and Q2, and you cannot use any loop. You are free to add helper methods, but you are not allowed to change the method header
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