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

A062714 Minimal length of a sequence with terms from {1, 2, 3, ..., n} which contains, as a subsequence, each possible ordering of the n symbols 1, 2, 3, ..., n.

Original entry on oeis.org

1, 3, 7, 12, 19, 28, 39, 52
Offset: 1

Views

Author

N. J. A. Sloane, Jul 14 2001

Keywords

Comments

For n >= 7, a(n) <= ceiling(n^2 - (7/3)*n + 19/3) as proved by Radomirovic (2012).
From Jon E. Schoenfield, Jul 27 2009: (Start)
For n > 2, a(n) <= (n-1)^2 + 3, and an easy solution at this upper bound can be obtained by cycling n-3 times through the digits 2 through n and appending the digits 2 and 3 once at the end, inserting a 1 at the beginning and after every n-2 digits thereafter until the last digit is reached, and finally prepending the digits 1 through n. For example:
n=3 (7 digits): 123 1 2 1 3
n=4 (12 digits): 1234 1 23 1 42 1 3
n=5 (19 digits): 12345 1 234 1 523 1 452 1 3
n=6 (28 digits): 123456 1 2345 1 6234 1 5623 1 4562 1 3
n=7 (39 digits): 1234567 1 23456 1 72345 1 67234 1 56723 1 45672 1 3
Equivalently, for n > 2, the i-th digit can be computed as
i for i <= n,
1 for i > n and (i-2) == 0 (mod (n-1)), and
(floor((i-1)*(n-2)/(n-1)) mod (n-1)) + 2 otherwise.
However, the above approach is not always optimal; e.g., at n = 16, it gives a valid solution in (16-1)^2 + 3 = 228 digits, but the following (using the letters a through g for the numbers 10 through 16) is an example of a 227-digit solution:
123456789a bcdefg1234 56789abcde f1g2345678 9abcde1f2g
3456789abc d1e2f3g456 789abc1d2e 3f4g56789a b1c2d3e4f5
g6789a1b2c 3d4e5f6g78 91a2b3c4d5 e6f7g8192a 3b4c5d6e7f
18g293a4b5 c6d17ef82g 394a5b16cd 7ef283g491 56abcd7e2f
3814569abc dg72e13456 89abcdf
(End)
Oliver Tan (2022) proves that for any integer s >= 2, there are infinitely many integers n for which there exists a sequence of length ceiling(n^2 - (5s-3)/(2s-1)*n + (2s^2+9s-7)/(2s-1)) which contains, as a subsequence, all permutations of a set of n symbols. In particular, if s=2, the above yields Radomirovic's expression. With s > 2, it produces shorter sequences than Radomirovic's for larger n. As s approaches infinity, the length approaches ceiling(n^2 - (5/2)*n + C). Formally, for any epsilon > 0, there is a constant C_epsilon such that there are infinitely many integers n for which there exists a sequence of length ceiling(n^2 - (5/2-epsilon)*n + C_epsilon). - Oliver Tan, Jan 22 2022

Examples

			1, 2, 3, 1, 2, 3, 1 contains as a subsequence all of 123, ..., 321 and is minimal, so a(3) = 7.
From _John W. Layman_, Aug 29 2008: (Start)
The following is a sequence of length a(5)=19 with terms from 1,2,...,5 that contains as subsequences all of the 120 permutations of 1,2,...,5:
{1,2,3,4,5,1,2,3,4,1,5,2,3,1,4,2,3,5,1}
The proof is shown here:
{1,2,3,4,5,-,-,-,-,-,-,-,-,-,-,-,-,-,-}
{1,2,3,-,5,-,-,-,4,-,-,-,-,-,-,-,-,-,-}
{1,2,-,4,-,-,-,3,-,-,5,-,-,-,-,-,-,-,-}
{1,2,-,4,5,-,-,3,-,-,-,-,-,-,-,-,-,-,-}
{1,2,-,-,5,-,-,3,4,-,-,-,-,-,-,-,-,-,-}
{1,2,-,-,5,-,-,-,4,-,-,-,3,-,-,-,-,-,-}
{1,-,3,-,-,-,2,-,4,-,5,-,-,-,-,-,-,-,-}
{1,-,3,-,-,-,2,-,-,-,5,-,-,-,4,-,-,-,-}
{1,-,3,4,-,-,2,-,-,-,5,-,-,-,-,-,-,-,-}
{1,-,3,4,5,-,2,-,-,-,-,-,-,-,-,-,-,-,-}
{1,-,3,-,5,-,2,-,4,-,-,-,-,-,-,-,-,-,-}
{1,-,3,-,5,-,-,-,4,-,-,2,-,-,-,-,-,-,-}
{1,-,-,4,-,-,2,3,-,-,5,-,-,-,-,-,-,-,-}
{1,-,-,4,-,-,2,-,-,-,5,-,3,-,-,-,-,-,-}
{1,-,-,4,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-,1,-,-,3,-,-}
{-,-,-,-,5,-,-,-,4,-,-,2,3,1,-,-,-,-,-}
{-,-,-,-,5,-,-,-,4,-,-,-,3,1,-,2,-,-,-}
{-,-,-,-,5,-,-,-,4,-,-,-,3,-,-,2,-,-,1}
(End)
		

Crossrefs

Cf. A136094 (smallest sequences), A351468 (Newey's sequences).
Cf. A049039, A337300 (conjectured values).
Cf. A373728 (circular), A180632 (superpermutations), A348574 (subset substrings).

Programs

  • Mathematica
    NextTuple[x_, n_, l_] := Module[{i, x0 = x},
       If[x0 == ConstantArray[n, l], Return[{}]];
       For[i = l, i >= 1, i--,
        If[x0[[i]] < n, x0[[i]]++; Return[x0], x0[[i]] = 1]]];
    Join[{1}, Table[p = Permutations[Range[n], {n}];
      For[tl = n + 1, tl <= 50, tl++,
       tup = ConstantArray[1, tl];
       While[tup = NextTuple[tup, n, tl]; tup != {},
        If[Product[Count[tup, i], {i, 1, n}] == 0, Continue[]];
        For[j = 1, j <= Length[p], j++,
         perm = p[[j]]; lst = tup; fnd = True;
         For[k = 1, k <= Length[perm], k++,
          If[lst == {}, fnd = False; Break[]];
          p1 = Position[lst, perm[[k]], 1, 1];
          If[Length[p1] == 0, fnd = False; Break[]];
          p1 = First@First@p1;
          If[! IntegerQ[p1], fnd = False; Break[]];
          lst = Drop[lst, p1];
          ]; If[! fnd, Break[]]]; If[fnd, Break[]]]; If[fnd, Break[]]];
    tl, {n, 2, 5}]](* Robert Price, Oct 13 2019 *)

Formula

Conjecture: a(n) = Sum_{k=1..n} A049039(k) = A337300(n). - Gerald Hillier, Jun 18 2016 [The conjecture is false for n=8, provided that a(8)=52 is correct. - Pontus von Brömssen, Aug 18 2025]

Extensions

a(5) = 19 from John W. Layman, Aug 29 2008
a(5)-a(7) are computed by Newey 1973, added by Max Alekseyev, Apr 16 2013
a(8) (using A136094) from Pontus von Brömssen, Aug 18 2025

A049039 Geometric Connell sequence: 1 odd, 2 even, 4 odd, 8 even, ...

Original entry on oeis.org

1, 2, 4, 5, 7, 9, 11, 12, 14, 16, 18, 20, 22, 24, 26, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 121, 123, 125
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A337300 (partial sums), A043529 (first differences).
Cf. A160464, A160465 and A160473. - Johannes W. Meijer, May 24 2009

Programs

  • Haskell
    a049039 n k = a049039_tabl !! (n-1) !! (k-1)
    a049039_row n = a049039_tabl !! (n-1)
    a049039_tabl = f 1 1 [1..] where
       f k p xs = ys : f (2 * k) (1 - p) (dropWhile (<= last ys) xs) where
         ys  = take k $ filter ((== p) . (`mod` 2)) xs
    -- Reinhard Zumkeller, Jan 18 2012, Jul 08 2011
    
  • Maple
    Digits := 100: [seq(2*n-1-floor(evalf(log(n)/log(2))), n=1..100)];
  • Mathematica
    a[0] = 0; a[n_?EvenQ] := a[n] = a[n/2]+n-1; a[n_?OddQ] := a[n] = a[(n-1)/2]+n; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Dec 27 2011, after Ralf Stephan *)
  • PARI
    a(n) = n<<1 - 1 - logint(n,2); \\ Kevin Ryde, Feb 12 2022
    
  • Python
    def A049039(n): return (n<<1)-n.bit_length() # Chai Wah Wu, Aug 01 2022

Formula

a(n) = 2n - 1 - floor(log_2(n)).
a(2^n-1) = 2^(n+1) - (n+2) = A000295(n+1), the Eulerian numbers.
a(0)=0, a(2n) = a(n) + 2n - 1, a(2n+1) = a(n) + 2n + 1. - Ralf Stephan, Oct 11 2003

Extensions

Keyword tabf added by Reinhard Zumkeller, Jan 22 2012

A122793 Connell sum sequence (partial sums of the Connell sequence).

Original entry on oeis.org

1, 3, 7, 12, 19, 28, 38, 50, 64, 80, 97, 116, 137, 160, 185, 211, 239, 269, 301, 335, 371, 408, 447, 488, 531, 576, 623, 672, 722, 774, 828, 884, 942, 1002, 1064, 1128, 1193, 1260, 1329, 1400, 1473, 1548, 1625, 1704, 1785, 1867, 1951, 2037, 2125, 2215, 2307, 2401, 2497, 2595, 2695, 2796, 2899, 3004, 3111, 3220
Offset: 1

Views

Author

Grady Bullington (bullingt(AT)uwosh.edu), Sep 14 2006

Keywords

Comments

a(n) is the sum of the n highest entries in the projection of the n-th tetrahedron or tetrahedral number (e.g., a(7) = 7+6+6+5+5+5+4+4).
a(n) is a sharp upper bound for the value of a gamma-labeling of a graph with n edges (cf. Bullington).

Crossrefs

Cf. A337300 (geometric Connell sums).

Programs

  • Python
    from math import isqrt
    def A122793(n): return n*(n+1)-(r:=(k:=isqrt(m:=n<<1))+int((m<<2)>(k<<2)*(k+1)+1))*((6*n+1)-r**2)//6 # Chai Wah Wu, Jul 26 2022

Formula

a(n) = (n-th triangular number) - n + (n-th partial sum of A122797).
a(n) = n^2 + n - R*((6*n+1)-R^2)/6, where R = round(sqrt(2*n)). - Gerald Hillier, Nov 29 2009
Showing 1-3 of 3 results.