0
public class Brain {

static int range;

double calculate() {
    double sum = 0;
    for (int n = 1; n <= Brain.range; n++) {

        sum = sum + (double) (1 / n);

    }

    return sum;

}

}

I am always getting the return as 1.0. I tried to understand it here, but no help : Harmonic sequence recursion

Community
  • 1
  • 1
Krishnendu
  • 125
  • 3
  • 13

0 Answers0