Exercise 4.1: fractionSum
NOTE: This problem seems to come from an oudated edition of the Building Java Programs textbook. Please make sure that you are solving the problem from the right edition of the textbook that you are using in your class. (Click here to jump to the current edition's version of this problem instead.)
Write a method called
fractionSum that accepts an integer parameter n and returns as a
double the sum of the first n terms of the sequence:
In other words, the method should generate the following sequence:
1 + (1/2) + (1/3) + (1/4) + (1/5) + ...
You may assume that the parameter n is non-negative.
Method problem: For this problem, you are supposed to write a Java method as described. You should not write a complete Java class; just write the method(s) described in the problem statement.
Contacting server and running tests...
Is there a problem?
Contact a Practice-It administrator.