Question: Java programming recursion The starter code is given: public class A1 { public static void main(String[] args) { // System.out.println(crazySeries(10)); // System.out.println(benNumber(3, 5)); } static
Java programming recursion
The starter code is given:
public class A1 { public static void main(String[] args) { // System.out.println(crazySeries(10)); // System.out.println(benNumber(3, 5)); } static int benNumber(int a, int b) { // TODO your code goes here } public static ArrayList crazySeries(int start) { // TODO your code goes here } } 
the input number must be greater than 0 , and you are not allowed to use loop here. For example, crazySeries(10)shouldreturnArrayList[10.,20.,40.,80.,160.,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.222222222222221,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
Get step-by-step solutions from verified subject matter experts
