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.

A232111 Numerator of smallest nonnegative fraction of form +- 1 +- 1/2 +- 1/3 ... +- 1/n.

Original entry on oeis.org

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

Views

Author

David W. Wilson, Nov 18 2013

Keywords

Comments

Sequence A231692 includes a proof that a(n) is never 0 for n > 1.

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, ...
		

Crossrefs

Cf. A232112 (denominators), A231692.

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