Remix.run Logo
Closest Harmonic Number to an Integer(johndcook.com)
23 points by ibobev 7 days ago | 3 comments
mackeye 23 minutes ago | parent | next [-]

> For small n we can directly implement the definition. For large n, the direct approach would be slow and would accumulate floating point error.

is there a reason the direct definition would be slow, if we cache the prior harmonic number to calculate the next?

jcla1 2 hours ago | parent | prev [-]

Interesting follow-up question: What is the distance between the set of harmonic numbers and the integers? i.e. is there a lower bound on the difference between a given integer and its closest harmonic number? If so, for which integer is this achieved?

jcla1 2 hours ago | parent [-]

Spoiler: there is a simple argument against the existence of such a lower bound.