Question
Sum series If you think recursively, you can solve many problems using recursion To solve a problem using recursion, you break it into subproblems. Identify,
Sum series
If you think recursively, you can solve many problems using recursion
To solve a problem using recursion, you break it into subproblems. Identify, define and describe the "problem" to be reduced
What are the input(s) and output(s)?
Design Using draw.io or Google Draw, create a flow chart of your design
just i case here's the code
package application;
//(Sum series) Calculate the following series using a recursive method: // m(i) = 1 / 3 + 2 / 5 + 3 / 7 + 4 / 9 + 5 / 11 + 6 / 13 + ... + i / (2i + 1)
public class Compute {
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
System.out.println("m(" + i + ") = " + computeSeries(i));
}
}
public static double computeSeries(int i) {
// base case
if (i == 1) {
return 1.0;
}
// recursive case
return (1.0 / i) + computeSeries(i-1);
}
}
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