Method to computer

Write a method to computer the following series: m(i) = 1/2 + 2/3 + . . . + i/i + 1
Write a test program that displays the following table: I m(i) 1 0.5000 2 1.1667 . . . 19 16.4023 20 17.3546
Formulas to achieve the above are: sum += k / (k + 1.0);
This would be placed within a for loop in the method m(). The for loop header can be written: for (int k = 1; k <= i; k++) One thing to notice here is the table. The results are for the numbers 1-20.

 
Powered by