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-4 of 4 results.

A003313 Length of shortest addition chain for n.

Original entry on oeis.org

0, 1, 2, 2, 3, 3, 4, 3, 4, 4, 5, 4, 5, 5, 5, 4, 5, 5, 6, 5, 6, 6, 6, 5, 6, 6, 6, 6, 7, 6, 7, 5, 6, 6, 7, 6, 7, 7, 7, 6, 7, 7, 7, 7, 7, 7, 8, 6, 7, 7, 7, 7, 8, 7, 8, 7, 8, 8, 8, 7, 8, 8, 8, 6, 7, 7, 8, 7, 8, 8, 9, 7, 8, 8, 8, 8, 8, 8, 9, 7, 8, 8, 8, 8, 8, 8, 9, 8, 9, 8, 9, 8, 9, 9, 9, 7, 8, 8, 8, 8
Offset: 1

Views

Author

Keywords

Comments

Equivalently, minimal number of multiplications required to compute the n-th power.

Examples

			For n < 149 and for many higher values of n, a(n) is the depth of n in a tree whose first 6 levels are shown below. The path from the root of the tree to n gives an optimal addition chain. (See Knuth, Vol. 2, Sect. 4.6.3, Fig. 14 and Ex. 5.)
                  1
                  |
                  2
                 / \
                /   \
               /     \
              /       \
             /         \
            3           4
           / \           \
          /   \           \
         /     \           \
        /       \           \
       5         6           8
      / \        |         /   \
     /   \       |        /     \
    7    10      12      9       16
   /    /  \    /  \    /  \    /  \
  14   11  20  15  24  13  17  18  32
E.g., a(15) = 5 and an optimal chain for 15 is 1, 2, 3, 6, 12, 15.
It is not possible to extend the tree to include the optimal addition chains for all n. For example, the chains for 43, 77, and 149 are incompatible. See the link to Achim Flammenkamp's web page on addition chains.
		

References

  • Hatem M. Bahig, Mohamed H. El-Zahar, and Ken Nakamula, Some results for some conjectures in addition chains, in Combinatorics, computability and logic, pp. 47-54, Springer Ser. Discrete Math. Theor. Comput. Sci., Springer, London, 2001.
  • D. Bleichenbacher and A. Flammenkamp, An Efficient Algorithm for Computing Shortest Addition Chains, Preprint, 1997.
  • A. Flammenkamp, Drei Beitraege zur diskreten Mathematik: Additionsketten, No-Three-in-Line-Problem, Sociable Numbers, Diplomarbeit, Bielefeld 1991.
  • S. B. Gashkov and V. V. Kochergin, On addition chains of vectors, gate circuits and the complexity of computations of powers [translation of Metody Diskret. Anal. No. 52 (1992), 22-40, 119-120; 1265027], Siberian Adv. Math. 4 (1994), 1-16.
  • A. A. Gioia and M. V. Subbarao, The Scholz-Brauer problem in addition chains, II, in Proceedings of the Eighth Manitoba Conference on Numerical Mathematics and Computing (Univ. Manitoba, Winnipeg, Man., 1978), pp. 251-274, Congress. Numer., XXII, Utilitas Math., Winnipeg, Man., 1979.
  • D. E. Knuth, The Art of Computer Programming, vol. 2, Seminumerical Algorithms, 2nd ed., Fig. 14 on page 403; 3rd edition, 1998, p. 465.
  • D. E. Knuth, website, further updates to Vol. 2 of TAOCP.
  • Michael O. Rabin and Shmuel Winograd, "Fast evaluation of polynomials by rational preparation." Communications on Pure and Applied Mathematics 25.4 (1972): 433-458. See Table p. 455.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Formula

a(n*m) <= a(n)+a(m). In particular, a(n^k) <= k * a(n). - Max Alekseyev, Jul 22 2005
For all n >= 2, a(n) <= (4/3)*floor(log_2 n) + 2. - Jonathan Vos Post, Oct 08 2008
From Achim Flammenkamp, Oct 26 2016: (Start)
a(n) <= 9/log_2(71) log_2(n), for all n.
It is conjectured by D. E. Knuth, K. Stolarsky et al. that for all n: floor(log_2(n)) + ceiling(log_2(v(n))) <= a(n). (End)
a(n) <= A014701(n). - Charles R Greathouse IV, Jan 03 2018
From Szymon Lukaszyk, Apr 05 2024: (Start)
For n = 2^s, a(n)=s;
for n = 2^s + 2^m, m in [0..s-1] (A048645), a(n)=s+1;
for n = 2^s + 3*2^m, m in [0..s-2] (A072823), a(n)=s+2;
for n = 2^s + 7*2^(s-3), s>2 (A072823), a(n)=s+2.(End)

Extensions

More terms from Jud McCranie, Nov 01 2001

A089265 a(1) = 0; thereafter a(2*n) = a(n) + 1, a(2*n+1) = 2*n.

Original entry on oeis.org

0, 1, 2, 2, 4, 3, 6, 3, 8, 5, 10, 4, 12, 7, 14, 4, 16, 9, 18, 6, 20, 11, 22, 5, 24, 13, 26, 8, 28, 15, 30, 5, 32, 17, 34, 10, 36, 19, 38, 7, 40, 21, 42, 12, 44, 23, 46, 6, 48, 25, 50, 14, 52, 27, 54, 9, 56, 29, 58, 16, 60, 31, 62, 6, 64, 33, 66, 18, 68, 35, 70, 11, 72
Offset: 1

Views

Author

Ralf Stephan, Oct 30 2003

Keywords

Comments

In the binary representation of n, swallow all zeros from the right, then add the number of swallowed zeros, and subtract 1. - Ralf Stephan, Aug 22 2013

Crossrefs

First differences of A005766.

Programs

  • Maple
    nmax:=73: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 1 to ceil(nmax/(p+2)) do a((2*n-1)*2^p) := p  + 2*(n-1) od: od: seq(a(n), n=1..nmax); # Johannes W. Meijer, Jan 23 2013
  • Mathematica
    a[n_] := With[{v = IntegerExponent[n, 2]}, v + n/2^v - 1];
    Array[a, 100] (* Jean-François Alcover, Feb 28 2019 *)
  • PARI
    a(n) = valuation(n,2) + n/2^valuation(n,2) - 1

Formula

a(1) = 0; thereafter a(2*n) = a(n) + 1, a(2*n+1) = 2*n.
a(n) = A007814(n) + 2*A025480(n-1) = A007814(n) + A000265(n) - 1.
G.f.: sum(k>=0, (t^2+2t^3-t^4)/(1-t^2)^2, t=(x^2)^k).
a((2*n-1)*2^p) = p + 2*(n-1), p >= 0. - Johannes W. Meijer, Jan 23 2013

A008057 Smallest sum of an addition chain for 2n+1.

Original entry on oeis.org

0, 5, 10, 16, 20, 27, 31, 35, 40, 47, 51, 56, 60, 65, 74, 78, 80, 86, 92, 96, 102, 106, 110, 120, 121, 125, 134, 137, 142, 148, 153, 156, 160, 167, 171, 182, 184, 185, 192, 201, 200, 206, 210, 219, 227, 231, 233, 237, 241, 245
Offset: 0

Views

Author

N. J. A. Sloane, Aug 07 2003

Keywords

Examples

			The smallest chain for 5 is 2, 3, 5 with sum a(2) = 2+3+5 = 10.
The smallest chain for 7 is 2, 3, 4, 7 with sum a(3) = 2+3+4+7 = 16.
		

Crossrefs

Programs

  • PARI
    step(V)=my(U=List(),v); for(i=1,#V, v=V[i]; for(i=1,#v, for(j=i,#v, if(v[i]+v[j]>v[#v], listput(U, concat(v, v[i]+v[j])))))); vecsort(Vec(U),,8)
    sm(v)=sum(i=2,#v,v[i])
    a(n)=if(n<2,return(5*n)); n=2*n+1; my(V=[[1,2]],U,t); while(#(U=select(v->v[#v]==n,V))==0, V=select(v->v[#v]<=n,step(V))); t=vecmin(apply(sm,U)); while(#V, V=step(select(v->sm(v)Charles R Greathouse IV, Jul 17 2013

Formula

a(n) = A376449(2*n+1) + 2*n. - Pontus von Brömssen, Apr 22 2025

Extensions

a(30)-a(46) from Sean A. Irvine, Mar 08 2018
a(47)-a(49) (using A376449 b-file) from Pontus von Brömssen, Apr 22 2025

A086833 Minimum number of different addends occurring in any shortest addition chain of Brauer type for a given n, or 0 if n has no shortest addition chain of Brauer type.

Original entry on oeis.org

1, 1, 1, 2, 2, 2, 2, 3, 2, 3, 3, 3, 3, 3, 3, 4, 4, 3, 3, 4, 3, 4, 5, 4, 4, 4, 3, 4, 4, 4, 4, 5, 5, 5, 4, 4, 4, 4, 4, 5, 5, 4, 6, 5, 4, 6, 4, 5, 5, 5, 5, 5, 5, 4, 4, 5, 4, 5, 5, 5, 5, 5, 4, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 6, 4, 6, 7, 5, 6, 7, 5, 6, 6, 5, 5, 7, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5
Offset: 1

Views

Author

Tatsuru Murai, Aug 08 2003

Keywords

Comments

n = 12509 is the first n for which a(n) = 0 because it is the smallest number that has no shortest addition chain of Brauer type. - Hugo Pfoertner, Jun 10 2006 [Edited by Pontus von Brömssen, Apr 25 2025]

Examples

			a(23)=5 because 23=1+1+2+1+4+9+5 is the shortest addition chain for 23.
For n=9 there are A079301(9)=3 different shortest addition chains, all of Brauer type:
[1 2 3 6 9] -> 9=1+1+1+3+3 -> 2 different addends {1,3}
[1 2 4 5 9] -> 9=1+1+2+1+4 -> 3 different addends {1,2,4}
[1 2 4 8 9] -> 9=1+1+2+4+1 -> 3 different addends {1,2,4}
The minimum number of different addends is 2, therefore a(9)=2.
		

Crossrefs

Formula

a(n) = 0 if and only if n is in A349044. - Pontus von Brömssen, Apr 25 2025

Extensions

Edited by Hugo Pfoertner, Jun 10 2006
Escape clause added by Pontus von Brömssen, Apr 25 2025
Showing 1-4 of 4 results.