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.

A232112 Denominator of smallest nonnegative fraction of form +- 1 +- 1/2 +- 1/3 ... +- 1/n.

This page as a plain text file.
%I A232112 #23 Nov 25 2021 12:34:28
%S A232112 1,1,2,6,12,60,20,420,840,2520,2520,27720,27720,360360,360360,360360,
%T A232112 144144,12252240,12252240,232792560,232792560,232792560,46558512,
%U A232112 5354228880,5354228880,2974571600,26771144400,80313433200
%N A232112 Denominator of smallest nonnegative fraction of form +- 1 +- 1/2 +- 1/3 ... +- 1/n.
%C A232112 Numerators are A232111.
%H A232112 David W. Wilson, <a href="/A232112/b232112.txt">Table of n, a(n) for n = 0..40</a>
%e A232112 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) = 60.
%e A232112 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, ...
%t A232112 nMax = 19; d = {0}; Table[d = Flatten[{d + 1/n, d - 1/n}]; Denominator[Min[Abs[d]]], {n, nMax}] (* _T. D. Noe_, Nov 20 2013 *)
%o A232112 (PARI) a(n,t=0)=if(n==1,denominator(abs(n-t)),min(a(n-1,t-1/n),a(n-1,t+1/n))) \\ _Charles R Greathouse IV_, Apr 06 2014
%o A232112 (Python)
%o A232112 from math import lcm, gcd
%o A232112 from itertools import product
%o A232112 def A232112(n):
%o A232112     if n <= 1: return 1
%o A232112     m = lcm(*range(2,n+1))
%o A232112     mtuple = tuple(m//i for i in range(2,n+1))
%o A232112     return m//gcd(m,min(abs(m+sum(d[i]*mtuple[i] for i in range(n-1))) for d in product((-1,1),repeat=n-1))) # _Chai Wah Wu_, Nov 25 2021
%Y A232112 Cf. A232111.
%K A232112 nonn,frac
%O A232112 0,3
%A A232112 _David W. Wilson_, Nov 18 2013