30

3

# How far should I sum?

The *harmonic series* is the "infinite sum" of all the fractions of the form \$\frac1n\$ for \$n\$ positive integer. I.e. the harmonic series is

$$\frac11 + \frac12 + \frac13 + \frac14 + \cdots$$

It is well-known that this sum diverges, which means that if you define

$$ H_n = \frac11 + \frac12 + \cdots + \frac1n$$

Then the value of \$H_n\$ goes to infinity. This can also be stated in a different way: for any positive value \$x\$ you pick, there is some value \$N\$ such that, to the right of \$N\$, the \$H\$ values are bigger than \$x\$:

$$\forall\ x\ \exists\ N: n > N \implies H_n > x $$

# Your task

Write a program/function that takes as input a positive number `x`

(not necessarily an integer) and outputs the first integer `n`

for which

$$H_n \geq x$$

In theory your program must work for arbitrary `x`

, even if in practice you are limited by the memory and/or precision of your programming language/computer.

# Test cases

```
1.5 -> 2
2 -> 4
3 -> 11
3.1415 -> 13
4 -> 31
5 -> 83
7.5 -> 1015
10 -> 12367
```

This is code-golf so shortest solution wins! Standard loopholes are forbidden by default. Happy golfing.

2Related OEIS sequence. – Arnauld – 2020-02-09T23:32:12.137

@Arnauld included for completeness? Or do you think it might help someone in any way? – RGS – 2020-02-09T23:43:35.103

9Your recent challenges have been great! Keep up the good work! – S.S. Anne – 2020-02-10T00:48:11.107

@S.S.Anne thanks :D I'll try to come up with more decent challenges. – RGS – 2020-02-10T07:27:49.817

You ask: "how far should I go". I suggest anywhere between 6 to 8 metres. :P – Lyxal – 2020-02-10T10:26:17.813

@Lyxal not far enough! – RGS – 2020-02-10T13:14:31.037