Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Recursion in Java 53.333333333333336,17.77777777777778,5.9259259259259265,1.9753086419753088]crazySeries(5)shouldreturnArrayList[5.,10.,20.,40.,80.,160.,53.333333333333336,17.77777777777778,5.9259259259259265,1.9753086419753088]crazySeries(1)shouldreturnArrayList[1.,2.,4.,8.,16.,32.,64.,128.,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
Recursion in Java
53.333333333333336,17.77777777777778,5.9259259259259265,1.9753086419753088]crazySeries(5)shouldreturnArrayList[5.,10.,20.,40.,80.,160.,53.333333333333336,17.77777777777778,5.9259259259259265,1.9753086419753088]crazySeries(1)shouldreturnArrayList[1.,2.,4.,8.,16.,32.,64.,128.,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 headerStep 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