# In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + … + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333… and so on. Assume that n is an integer variable whose value is some positive integer N. Assume also that hn is a variable whose value is the Nth harmonic number. Write an expression whose value is the (N+1)th harmonic number.

3

### CHALLENGE:

In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + … + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333… and so on. Assume that n is an integer variable whose value is some positive integer N. Assume also that hn is a variable whose value is the Nth harmonic number. Write an expression whose value is the (N+1)th harmonic number.

### SOLUTION:

```
hn + 1.0 / (n + 1)
```

• Casey says:

Why is, in the answer, you get 1.0 instead of just 1? Why is the .0 necessary?

• me says:

so the function takes it as a float or double instead of an integer, if it takes it as an integer, the number would be approached to the nearest whole number deleting the decimal places, and we need those decimals for our answer.

• austin says:

1 is a an int 1.0 is a double
3 / 2 = 1
3.0 / 2.0 = 1.5