logoalt Hacker News

Closest Harmonic Number to an Integer

32 pointsby ibobev11/20/202510 commentsview on HN

Comments

charlieyu1today at 4:39 PM

Pretty crazy that H_n - ln(n) has a series expansion with rational coefficients except the constant term

mackeyetoday at 3:03 PM

> 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?

show 2 replies
jcla1today at 1:52 PM

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?

show 3 replies
anthktoday at 7:54 PM

On this https://www.johndcook.com/blog/special-numbers/ I remember the 'schizofrenic numbers'.