Here is the Hints on Exercise HarmonicSum (Loop)
public class HarmonicSum { // saved as "HarmonicSum.java"
public static void main (String[] args) {
int maxDenominator = 50000;
double sumL2R = 0.0; // sum from left-to-right
double sumR2L = 0.0; // sum from right-to-left
// for-loop for summing from left-to-right
for (int denominator = 1; denominator <= maxDenominator; ++denominator) {
......
// Beware that int/int gives int.
}
// for-loop for summing from right-to-left
......
// Find the difference and display
......
}
}
No Comment to " Hints on Exercise HarmonicSum (Loop) "