A363937 Minimal number of terms of an Egyptian fraction to be added to, or subtracted from, harmonic number H(n) to get an integer.
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
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.
Links
- Ron Knott, Egyptian Fractions
Crossrefs
Cf. A281530
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
Comments