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.

Showing 1-2 of 2 results.

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

Original entry on oeis.org

1, 1, 2, 6, 12, 60, 20, 420, 840, 2520, 2520, 27720, 27720, 360360, 360360, 360360, 144144, 12252240, 12252240, 232792560, 232792560, 232792560, 46558512, 5354228880, 5354228880, 2974571600, 26771144400, 80313433200
Offset: 0

Views

Author

David W. Wilson, Nov 18 2013

Keywords

Comments

Numerators are A232111.

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) = 60.
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. A232111.

Programs

  • Mathematica
    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 *)
  • 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
    
  • Python
    from math import lcm, gcd
    from itertools import product
    def A232112(n):
        if n <= 1: return 1
        m = lcm(*range(2,n+1))
        mtuple = tuple(m//i for i in range(2,n+1))
        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

A349544 Smallest possible value of |Sum_{k=0..n} (+-) 2^k * 3^(n-k)|, where each (+-) can be either plus or minus sign, independently for each term in the sum.

Original entry on oeis.org

1, 1, 1, 5, 1, 19, 7, 5, 65, 61, 73, 227, 257, 5, 439, 1253, 2425, 2035, 833, 2677, 10591, 6509, 32071, 41173, 77263, 114323, 18145, 129685, 321151, 15757, 645449, 113957, 50735, 477653, 24295, 5089013, 3743881, 4809115, 12209455, 8216179, 32894927, 80299843, 45673913
Offset: 0

Views

Author

Vladimir Reshetnikov, Nov 21 2021

Keywords

Comments

All terms are positive odd integers.

Examples

			For n = 3, there are 2^3 = 8 possible choices of signs: 3^3 + 2*3^2 + 2^2*3 + 2^3 = 65, 3^3 + 2*3^2 + 2^2*3 - 2^3 = 49, 3^3 + 2*3^2 - 2^2*3 + 2^3 = 41, 3^3 + 2*3^2 - 2^2*3 - 2^3 = 25, 3^3 - 2*3^2 + 2^2*3 + 2^3 = 29, 3^3 - 2*3^2 + 2^2*3 - 2^3 = 13, 3^3 - 2*3^2 - 2^2*3 + 2^3 = 5, and 3^3 - 2*3^2 - 2^2*3 - 2^3 = -11. The smallest absolute value is 5, so a(3) = 5.
		

Crossrefs

Programs

  • Maple
    b:= proc(k, n) option remember; `if`(k<0, {0}, map(x->
         (t-> [x+t, abs(x-t)][])(2^(n-k)*3^k), b(k-1, n)))
        end:
    a:= n-> min(b(n$2)):
    seq(a(n), n=0..18);  # Alois P. Heinz, Nov 21 2021
  • Mathematica
    Min@*Abs/@FoldList[Join[3 #1 + 2^#2, 3 #1 - 2^#2] &, {1}, Range[25]]
  • Python
    def f(k,n):
        if k == 0 and n == 0: return (x for x in (1,))
        if k < n: return (y*3 for y in f(k,n-1))
        return (abs(x+y) for x in f(k-1,n) for y in (2**n,-2**n))
    def A349544(n): return min(f(n,n)) # Chai Wah Wu, Nov 24 2021

Extensions

a(33)-a(35) from Chai Wah Wu, Nov 24 2021
a(36)-a(42) from Martin Ehrenstein, Nov 26 2021
Showing 1-2 of 2 results.