A232111 Numerator of smallest nonnegative fraction of form +- 1 +- 1/2 +- 1/3 ... +- 1/n.
0, 1, 1, 1, 1, 7, 1, 11, 13, 11, 11, 23, 23, 607, 251, 251, 25, 97, 97, 3767, 3767, 3767, 457, 24319, 24319, 7951, 4261, 13703, 13703, 872843, 872843, 17424097, 13828799, 902339, 7850449, 7850449, 7850449, 1526171, 68185267, 3429883, 3429883
Offset: 0
Examples
1-1/2-1/3-1/4+1/5 = 7/60. No other choice of term signs yields a smaller nonnegative fraction, so a(5) = 7. 0/1, 1/1, 1/2, 1/6, 1/12, 7/60, 1/20, 11/420, 13/840, 11/2520, 11/2520, 23/27720, 23/27720, 607/360360, 251/360360, 251/360360, 25/144144, 97/12252240, ...
Programs
-
Mathematica
nMax = 19; d = {0}; Table[d = Flatten[{d + 1/n, d - 1/n}]; Numerator[Min[Abs[d]]], {n, nMax}] (* T. D. Noe, Nov 20 2013 *)
-
PARI
a(n,t=0)=if(n==1,numerator(abs(n-t)),min(a(n-1,t-1/n),a(n-1,t+1/n))) \\ Charles R Greathouse IV, Apr 06 2014
-
Python
from itertools import product from fractions import Fraction def A232111(n): return min(x for x in (sum(d[i]*Fraction(1,i+1) for i in range(n)) for d in product((1,-1),repeat=n)) if x >= 0).numerator # Chai Wah Wu, Nov 24 2021
Comments