cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A363937 Minimal number of terms of an Egyptian fraction to be added to, or subtracted from, harmonic number H(n) to get an integer.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 2, 3, 4, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 4, 5, 5, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6
Offset: 1

Views

Author

Denis Ivanov, Jun 29 2023

Keywords

Comments

The shortest Egyptian fractions for H(n) - floor(H(n)) and ceiling(H(n)) - H(n) are calculated and the smaller length of those fractions is a(n).

Examples

			For n = 2: H(2) = 3/2 which is between 1 and 2 and they are reached by the same H(2) - 1 = 2 - H(2) = 1/2 which is 1 term, so a(2) = 1.
For n = 5: H(5) = 137/60 is between 2 and 3; going up 3 - H(5) = 1/2 + 1/6 + 1/20 is 3 terms but going down H(5) - 2 = 1/5 + 1/12 is 2 terms, so the latter is shorter and a(5) = 2 terms.
		

Crossrefs

Programs

  • Mathematica
    (* Thanks to Ron Knott for the algorithm. Slow for n>15. *)
    check[f_, k_]:= (If[Numerator@f == 1, Return@True];
      If[k == 1, Return@False];
      Catch[Do[
        If[check[f - 1/i, k - 1], Throw@True],
        {i, Range[Ceiling[1/f],Floor[k/f]]}];
       Throw@False]
      );
    a[n_]:= (h = HarmonicNumber[n];
      d = {h - Floor[h], Ceiling[h] - h};
      j = 1;
      While[Not[Or @@ (check[#, j] & /@ d)], j++]; j);

Extensions

a(31)-a(45) from Dmitry Petukhov, Jul 24 2023