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.
%I A363937 #68 Sep 22 2023 05:29:29 %S A363937 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, %T A363937 5,5,5,5,5,6,6,6,6,6,6 %N A363937 Minimal number of terms of an Egyptian fraction to be added to, or subtracted from, harmonic number H(n) to get an integer. %C A363937 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). %H A363937 Ron Knott, <a href="https://r-knott.surrey.ac.uk/Fractions/egyptian.html">Egyptian Fractions</a> %e A363937 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. %e A363937 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. %t A363937 (* Thanks to Ron Knott for the algorithm. Slow for n>15. *) %t A363937 check[f_, k_]:= (If[Numerator@f == 1, Return@True]; %t A363937 If[k == 1, Return@False]; %t A363937 Catch[Do[ %t A363937 If[check[f - 1/i, k - 1], Throw@True], %t A363937 {i, Range[Ceiling[1/f],Floor[k/f]]}]; %t A363937 Throw@False] %t A363937 ); %t A363937 a[n_]:= (h = HarmonicNumber[n]; %t A363937 d = {h - Floor[h], Ceiling[h] - h}; %t A363937 j = 1; %t A363937 While[Not[Or @@ (check[#, j] & /@ d)], j++]; j); %Y A363937 Cf. A281530 %K A363937 nonn,more %O A363937 1,5 %A A363937 _Denis Ivanov_, Jun 29 2023 %E A363937 a(31)-a(45) from _Dmitry Petukhov_, Jul 24 2023