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.

Previous Showing 51-60 of 65 results. Next

A293771 Minimum number of steps needed to compute n using a machine that can read, write and add starting with the number 1.

Original entry on oeis.org

0, 2, 3, 4, 5, 5, 6, 6, 6, 7, 8, 7, 8, 8, 8, 8, 9, 8, 9, 9, 9, 10, 10, 9, 10, 10, 9, 10, 11, 10, 11, 10, 11, 11, 11, 10, 11, 11, 11, 11, 12, 11, 12, 12, 11, 12, 12, 11, 12, 12, 12, 12, 13, 11, 12, 12, 12, 13, 13, 12, 13, 13, 12, 12, 13, 13, 14, 13, 13, 13, 14, 12, 13, 13, 13, 13, 14, 13, 14, 13, 12, 13, 14, 13, 14, 14, 14, 14, 15
Offset: 1

Views

Author

Floris P. van Doorn, Oct 15 2017

Keywords

Comments

The machine has a cache which holds 1 integer and a memory which holds a list of integers.
The machine starts with a number 1 in cache and empty memory.
At every step, the machine can do one of three things:
(1) write the number from cache to a new position in memory;
(2) read any number from memory and put it in cache;
(3) add any number from memory to the number in cache.
a(n) is the minimum number of steps needed to get the number n in cache.
Conjecture: reading from memory (operation 2) is never needed to get to a number in the minimal number of steps.
Additional conjectures and comments by Glen Whitney, Oct 12 2021: (Start)
Conjecture II: For each n, there is a minimal-length program for n that stores numbers in memory in increasing order.
Conjecture III: For each n, there is a minimal-length program such that the difference between successive numbers stored in memory is strictly increasing.
All three conjectures are empirically verified for all programs of length 23 or less, and all values of n up to 2326. However, note that if you are allowed to specify the set of numbers that must be stored in memory, then the first conjecture fails for memory {1,3,9,27,30,54} and conjecture II fails for {1,3,9,27,30,54,60}. (These sequences of numbers in memory are similar to addition chains, see A003313.) Hence, a proof of the first conjecture might need to involve showing that every n has a "good" sequence of numbers that can be stored in memory to produce n, avoiding the need to invoke the read operation. Conjecture III supplies one speculative possibility of a property that might fill the role of "good." A proof of any of these conjectures would tremendously speed up computation of a(n) as compared to brute force. (End)
One can add a useless read instruction after the first operation of writing the initial one in cache to memory. Therefore, there is always a program one step longer than optimal that performs a read. Thus, in a numerical search, the first sign one might observe that read operations can be helpful is a tie for shortest between a program that does read and one that doesn't, for some value of n. However, no such ties occur for program length 21 or less. - Glen Whitney, Oct 23 2021

Examples

			For n = 23 we need 10 steps to get 23 in cache:
   1. Write 1 to memory
   2. Add 1 to cache (cache contains 2)
   3. Write 2 to memory
   4. Add 2 to cache (cache contains 4)
   5. Add 2 to cache (cache contains 6)
   6. Add 1 to cache (cache contains 7)
   7. Write 7 to memory
   8. Add 7 to cache (cache contains 14)
   9. Add 7 to cache (cache contains 21)
  10. Add 2 to cache (cache contains 23)
There are several other essentially different 10-step programs that result in 23 in cache, but no 9-step programs. (If a program differs just by the order of a sequence of successive additions, it's not considered essentially different.) Note that for all n < 2326, all of the numbers that have an essentially unique minimal program that puts a maximal set of numbers in memory are of the form 2^k, 1+2^k, 3^k, or 1+3^k, except for 5, 809 and 1609:
For n = 809 we need 21 steps: (1) W1; (2) A1 => 2; (3) A1 => 3; (4) W3; (5) A3 => 6; (6) A3 => 9; (7) A1 => 10; (8) W10; (9) A10 => 20; (10) W20; (11) A20 => 40; (12) W40; (13) A40 => 80; (14) W80; (15) A80 => 160; (16) A80 => 240; (17) A3 => 243; (18) W243; (19) A243 => 486; (20) A243 => 729; (21) A80 => 809.
n = 1609 can be computed most efficiently in 23 steps. The contents of memory when 1609 is reached are {1,3,10,20,40,80,160,483}; the precise steps can be inferred from these memory contents.
		

Crossrefs

Cf. A003313 (addition chains; similar except read/write are "free").

Programs

  • Mathematica
    PossibleNextStates[{n_, l_}] :=
    Join[{#, l} & /@ l,
      If[! MemberQ[l, n], {{n, Sort@Append[l, n]}}, {}], {n + #, l} & /@ l]
    states = {{1, {}}}; i = 0; c[1] = 0;
    Do[states = Union @@ PossibleNextSteps /@ states; i++;
      If[! IntegerQ[c[#[[1]]]], c[#[[1]]] = i] & /@ states, {14}];
    c /@ Range[88]

A349044 Non-Brauer numbers.

Original entry on oeis.org

12509, 13207, 13705, 15473, 16537, 20753, 22955, 23219, 23447, 24797, 25018, 26027, 26253, 26391, 26414, 26801, 27401, 27410, 30897, 30946, 31001, 32921, 33065, 33074, 41489, 41506, 43755, 43927, 45867, 46355, 46419, 46797, 46871, 46894, 47761, 49373, 49577, 49593, 49594, 49611, 50036, 50829, 51667
Offset: 1

Views

Author

Glen Whitney, Nov 06 2021

Keywords

Comments

A sequence 1=a_0 < a_1 < a_2 < ... < a_l = n is an addition chain (of length l) for n if for each i, 0 < i <= l, there are j_i and k_i such that a_i = a_j_i + a_k_i. Such a chain is called a star-chain or Brauer chain if in addition each j_i = i-1. A number is a Brauer number if among its shortest addition chains there is a Brauer chain, and non-Brauer otherwise.
The length of a shortest Brauer chain for n is often denoted l^*(n). A003313(n) gives the length of a shortest addition chain for n. Thus n is in this sequence if and only if A003313(n) < l^*(n).
For entries at least through 41506, these numbers satisfy l^*(n) = A003313(n) + 1. It seems likely that larger differences between l^*(n) and A003313(n) occur for later entries in this sequence, but it is unclear whether any n with a larger difference have been found.
These differences between l^*(n) and A003313(n) are highlighted by the following formulation: consider a machine which starts with a 1 in "cache" and can then at each step execute one of two operations: (1) Add any number that has ever been in cache to the current contents of cache, or (2) Restore any number that has previously been in cache to the cache, replacing its prior contents. Then n is in this sequence if and only if there is a shortest program that results in n in cache that includes a "Restore" step. Note further that if there is an entry in this sequence such that l^*(n) > A003313(n)+1, then all shortest programs producing n in cache would contain a "Restore" operation. The definition of A293771 is based on a similar machine with a separate "Store" operation that puts the cache value into "memory," and one could formulate an analogous conjecture here that the "Restore" operation is never necessary for a shortest program. The existence or not of an n in this sequence such that l^*(n) > A003313(n)+1 would settle this question and provide mild evidence one way or the other on the conjecture in A293771.

Examples

			The shortest star-chains for 12509 have length 18; one example is 1,2,3,4,7,11,18,25,43,86,172,344,688,1376,1401,2777,5554,6955,12509. (By inspection, each number in this chain is the sum of the prior number and another number in the sequence, possibly also the prior number.) On the other hand, there are addition chains of length 17 for 12509, e.g., 1,2,4,6,12,13,24,48,96,192,384,768,781,1562,3124,6248,12496,12509. (Here a_5 = a_3+a_3, preventing this from being a star-chain.) All numbers smaller than 12509 include a star chain among their shortest addition chains (by exhaustive search). Hence 12509 is the first number in this sequence.
		

Crossrefs

Cf. A003313, the length of a shortest addition chain for n.
Cf. A079301, A079302, the number of shortest addition chains for n which are Brauer chains and which are non-Brauer chains, respectively.

Formula

A079301(n) = 0 if and only if n occurs in this sequence.

A376449 Smallest sum of addition chain for n.

Original entry on oeis.org

0, 1, 3, 3, 6, 6, 10, 7, 12, 11, 17, 12, 19, 17, 21, 15, 24, 21, 29, 21, 31, 28, 34, 24, 36, 32, 39, 31, 46, 36, 48, 31, 48, 41, 52, 39, 56, 48, 58, 41, 62, 52, 64, 50, 66, 57, 74, 48, 73, 61, 75, 58, 82, 66, 83, 59, 86, 75, 90, 66, 93, 79, 94, 63, 96, 81, 101, 75, 103, 87, 112, 75, 112, 93, 111
Offset: 1

Views

Author

Roy van Rijn, Sep 23 2024

Keywords

Comments

There are multiple ways to get a shortest addition chain (A003313), this sequence is the smallest sum of the possible chains.

Examples

			Here are the smallest examples:
   n : a(n)
   1 :  0    []
   2 :  1    [1]
   3 :  3    [1, 2]
   4 :  3    [1, 2]
   5 :  6    [1, 2, 3]
   6 :  6    [1, 2, 3]
   7 : 10    [1, 2, 3, 4]
   8 :  7    [1, 2, 4]
   9 : 12    [1, 2, 4, 5]
  10 : 11    [1, 2, 3, 5]
  11 : 17    [1, 2, 3, 5, 6]
  12 : 12    [1, 2, 3, 6]
  13 : 19    [1, 2, 3, 6, 7]
  14 : 17    [1, 2, 3, 4, 7]
  15 : 21    [1, 2, 3, 6, 9]
  16 : 15    [1, 2, 4, 8]
  17 : 24    [1, 2, 4, 8, 9]
  18 : 21    [1, 2, 4, 5, 9]
  19 : 29    [1, 2, 3, 4, 8, 11]
  20 : 21    [1, 2, 3, 5, 10]
  ...
		

Crossrefs

Formula

For n = 2^s, a(n) = n-1.
For odd n, a(n) = A008057((n-1)/2) - n + 1. - Pontus von Brömssen, Apr 22 2025

A383329 Number of multiplications required to compute x^n by Knuth's power tree method.

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, 9, 8, 9, 7, 8, 8, 8, 8, 8, 8, 9
Offset: 1

Views

Author

Pontus von Brömssen, Apr 24 2025

Keywords

Comments

n appears in row a(n)+1 of A114622.
n appears A114623(n+1) times.
First differs from A003313 at n = 77.

References

  • Donald E. Knuth, The Art of Computer Programming, Vol. 2, 3rd edition, Addison-Wesley, 1998. See page 464.

Crossrefs

Cf. A003313, A113945, A114622, A114623, A115617 (indices of records), A122352.

Formula

a(n) = a(A122352(n)) + 1 for n >= 2.
a(A115617(k)) = k and a(n) < k for n < A115617(k).

A117498 Optimal combination of binary and factor methods for finding an addition chain.

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, 7, 5, 6, 6, 6, 6, 7, 6, 7, 5, 6, 6, 7, 6, 7, 7, 7, 6, 7, 7, 8, 7, 7, 8, 9, 6, 7, 7, 7, 7, 8, 7, 8, 7, 8, 8, 9, 7, 8, 8, 8, 6, 7, 7, 8, 7, 8, 8, 9, 7, 8, 8, 8, 8, 9, 8, 9, 7, 8, 8, 9, 8, 8, 9, 9, 8, 9, 8, 9, 9, 9, 10, 9, 7, 8, 8, 8, 8, 9, 8, 9, 8, 9
Offset: 1

Views

Author

Keywords

Comments

This is an upper bound for both addition chains (A003313) and A117497. The first few values where A003313 is smaller are 23,43,46,47,59. The first few values where A117497 is smaller are 77,143,154,172,173. The first few values where both are smaller are 77,154,172,173,203.
For a function f from a finite set X to itself, let I(f) be the number of subsets A of X, which are f-stable in the sense that f(A) is contained in A. Then a(n) is the smallest positive integer m, such that a function f exists on a set with m elements, so that I(f) = n. The f-stable subsets form a finite topology on X, which implies that A137813 is a lower bound. The first index where A137813 is smaller is 23. - Qiaochu Yuan, Jun 27 2024

Examples

			a(33)=6 because 6 = 1+a(32) < a(3)+a(11) = 2+5. a(36) = min(a(35)+1, a(2)+a(18), a(3)+a(12), a(4)+a(9), a(6)+a(6)) = min(1+7, 1+5, 2+4, 2+4, 3+3) = 6.
		

Crossrefs

Formula

a(1)=0; a(n) = min(a(n-1)+1, min_{d|n, 1

A117632 Number of 1's required to build n using {+,T} and parentheses, where T(i) = i*(i+1)/2.

Original entry on oeis.org

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

Author

Jonathan Vos Post, Apr 08 2006

Keywords

Comments

This problem has the optimal substructure property.

Examples

			a(1) = 1 because "1" has a single 1.
a(2) = 2 because "1+1" has two 1's.
a(3) = 2 because 3 = T(1+1) has two 1's.
a(6) = 2 because 6 = T(T(1+1)).
a(10) = 3 because 10 = T(T(1+1)+1).
a(12) = 4 because 12 = T(T(1+1)) + T(T(1+1)).
a(15) = 4 because 15 = T(T(1+1)+1+1).
a(21) = 2 because 21 = T(T(T(1+1))).
a(28) = 3 because 28 = T(T(T(1+1))+1).
a(55) = 3 because 55 = T(T(T(1+1)+1)).
		

References

  • W. A. Beyer, M. L. Stein and S. M. Ulam, The Notion of Complexity. Report LA-4822, Los Alamos Scientific Laboratory of the University of California, Los Alamos, NM, 1971.
  • R. K. Guy, Unsolved Problems Number Theory, Sect. F26.

Crossrefs

See also A023361 = number of compositions into sums of triangular numbers, A053614 = numbers that are not the sum of triangular numbers. Iterated triangular numbers: A050536, A050542, A050548, A050909, A007501.

Programs

  • Maple
    a:= proc(n) option remember; local m; m:= floor (sqrt (n*2));
          if n<3 then n
        elif n=m*(m+1)/2 then a(m)
        else min (seq (a(i)+a(n-i), i=1..floor(n/2)))
          fi
        end:
    seq (a(n), n=1..110);  # Alois P. Heinz, Jan 05 2011
  • Mathematica
    a[n_] := a[n] = Module[{m = Floor[Sqrt[n*2]]}, If[n < 3, n, If[n == m*(m + 1)/2, a[m], Min[Table[a[i] + a[n - i], {i, 1, Floor[n/2]}]]]]];
    Array[a, 110] (* Jean-François Alcover, Jun 02 2018, from Maple *)

Extensions

I do not know how many of these entries have been proved to be minimal. - N. J. A. Sloane, Apr 15 2006
Corrected and extended by Alois P. Heinz, Jan 05 2011

A118387 Record values in A079300 (number of shortest addition chains of n).

Original entry on oeis.org

1, 2, 5, 15, 33, 40, 132, 220, 352, 1258, 2661, 3903, 9787, 12989, 17961, 31373, 33076, 55262, 110624
Offset: 1

Author

David W. Wilson, Apr 26 2006

Keywords

Comments

Computed by Neill M. Clift. Verified up to a(17) by David W. Wilson.

References

Crossrefs

Formula

a(n) = A079300(A118386(n)).

A186435 Number of evaluation schemes for x^n achieving the minimal number of multiplications.

Original entry on oeis.org

1, 1, 1, 1, 2, 2, 6, 1, 3, 4, 19, 3, 10, 16, 4, 1, 2, 7, 37, 6, 31, 48, 4, 4, 14, 24, 5, 26, 152, 12, 80, 1, 2, 4, 51, 12, 39, 100, 20, 8, 23, 90, 4, 81, 14, 8, 242, 5, 12, 36, 4, 38, 215, 16, 172, 36, 190, 395, 40, 24
Offset: 1

Author

Laurent Thevenoux and Christophe Mouilleron, Feb 23 2011

Keywords

Examples

			For n=7, we can evaluate x^7 using only 4 multiplications in 6 ways:
x^2 = x * x ; x^3 = x   * x^2 ; x^4 = x   * x^3 ; x^7 = x^3 * x^4
x^2 = x * x ; x^3 = x   * x^2 ; x^4 = x^2 * x^2 ; x^7 = x^3 * x^4
x^2 = x * x ; x^3 = x   * x^2 ; x^5 = x^2 * x^3 ; x^7 = x^2 * x^5
x^2 = x * x ; x^3 = x   * x^2 ; x^6 = x^3 * x^3 ; x^7 = x   * x^6
x^2 = x * x ; x^4 = x^2 * x^2 ; x^5 = x   * x^4 ; x^7 = x^2 * x^5
x^2 = x * x ; x^4 = x^2 * x^2 ; x^6 = x^2 * x^4 ; x^7 = x   * x^6
		

Crossrefs

See A003313 for the minimal number of multiplications to evaluate x^n.
See A001190 for the total number of evaluation schemes for x^n (regardless of the number of effective multiplications).
A079300 gives the number of minimal chains (= sequences of powers of x) ending at x^n. This is actually a bit less than the number of evaluation schemes since two schemes may produce the same chain, like the first and second schemes in the example above, where the corresponding chain is (x^2, x^3, x^4, x^7).

A186437 Maximal number of squarings in an evaluation scheme for x^n achieving the minimal number of operations.

Original entry on oeis.org

0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 4, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
Offset: 1

Author

Laurent Thévenoux and Christophe Mouilleron, Feb 23 2011

Keywords

Comments

a(n) is also the maximal number of doublings in a shortest addition chain for n.

Examples

			For n=5, we can evaluate x^5 using only 3 operations in 2 ways:
  x^2 = (x)^2; x^3 = x * x^2; x^5 = x^2 * x^3
  x^2 = (x)^2; x^4 = (x^2)^2; x^5 = x * x^4
The second way achieves the maximal number of doublings, which is a(5) = 2.
		

Crossrefs

Formula

We have a(n) = floor(log_2(n)) for all n ≤ 60 except 23, 39, 43 and 46.

A353058 Minimum number of iterations {add or subtract 1, or half if even} needed to reach 1, starting from 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, 7, 6, 7, 6, 6, 5, 6, 6, 7, 6, 7, 7, 7, 6, 7, 7, 8, 7, 8, 7, 7, 6, 7, 7, 8, 7, 8, 8, 8, 7, 8, 8, 8, 7, 8, 7, 7, 6, 7, 7, 8, 7, 8, 8, 8, 7, 8, 8, 9, 8, 9, 8, 8, 7, 8, 8, 9, 8, 9, 9, 9, 8
Offset: 1

Author

M. F. Hasler, Apr 20 2022

Keywords

Comments

At each iteration, one may choose from one of the three operations: add 1, subtract 1, or, if the number is even, divide by two. a(n) gives the minimum number of iterations required to reach 1, starting from n.
This differs from A003313 (length of shortest addition chain), A128998 (length of shortest addition-subtraction chain) and A137813 (minimal set with n-topology) starting at index n = 27 where a(27) = 7 while the other three have A(27) = 6.

Examples

			For n = 1, the value 1 is already reached, so a(1) = 0 iterations are needed.
For n = 2, one can either subtract 1 or divide by 2 to reach 1, i.e., a(2) = 1 iterations are needed.
For n = 3, one must subtract 1 twice in order to reach the goal 1 in the minimum number of a(3) = 2 steps: Initially, one cannot divide by 2 since 3 is even, and if 1 is added, to get 3 + 1 = 4, at least two divisions by 2 (for a total of 3 steps) would be needed to reach 1.
For n = 7, the fastest is to add 1 (to get 7 + 1 = 8) and then divide three times by 2, to reach 1 in the minimum number of a(7) = 4 steps.
		

Crossrefs

Cf. A003313 (shortest addition chain), A137813 (minimal set with n-topology), A128998 (shortest addition-subtraction chain).

Programs

  • PARI
    apply( {A353058(n,o=[n])=for(i=0,n,o[1]>1||return(i);o=Set(concat([if(n%2,[n-1,n+1],n\2)|n<-o])))}, [1..90])

Formula

log_2(n) <= a(n) <= log_2(n)*3/2.
The maximum of a(n) - log_2(n) is reached for numbers which have the binary expansion {10}*11 or 1{10}*11, where {10}* means any nonzero number of repetitions of '10'.
a(n) = A061339(n)-1. - Rémy Sigrist, Apr 22 2022
Previous Showing 51-60 of 65 results. Next