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.

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

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.