Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I solve this problem with recursion in JAVA? Please please please don't use while loop! Question: In this session, you need to implement

How can I solve this problem with recursion in JAVA? Please please please don't use while loop!

Question:

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) should return ArrayList [10.0, 20.0, 40.0, 80.0, 160.0, 53.333333333333336, 17.77777777777778, 5.9259259259259265, 1.9753086419753088]

crazySeries(5) should return ArrayList [5.0, 10.0, 20.0, 40.0, 80.0, 160.0, 53.333333333333336, 17.77777777777778, 5.9259259259259265, 1.9753086419753088]

crazySeries(1) should return ArrayList [1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 42.666666666666664, 14.222222222222221, 4.7407407407407405]

Starter Code is given as below:

public class A1 {

public static void main(String[] args) {

System.out.println(crazySeries(10));

System.out.println(crazySeries(5));

System.out.println(crazySeries(1));

}

public static ArrayList crazySeries(int start) {

// Code

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

303139688X, 978-3031396885

More Books

Students also viewed these Databases questions