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 137 results. Next

A266540 Partial sums of A266539.

Original entry on oeis.org

0, 0, 1, 2, 3, 4, 7, 10, 11, 12, 15, 18, 23, 28, 35, 42, 43, 44, 47, 50, 55, 60, 67, 74, 83, 92, 103, 114, 127, 140, 155, 170, 171, 172, 175, 178, 183, 188, 195, 202, 211, 220, 231, 242, 255, 268, 283, 298, 315, 332, 351, 370, 391, 412, 435, 458, 483, 508, 535, 562, 591, 620, 651, 682, 683, 684, 687, 690, 695, 700
Offset: 1

Views

Author

Omar E. Pol, Jan 02 2016

Keywords

Comments

Also A266535 and twice the terms of A256249 interleaved, or in other words A266535 and A266538 interleaved.
It appears that this sequence has a fractal (or fractal-like) behavior.
First differs from both A266510 and A266530 at a(25), with which it shares infinitely many terms.
For an illustration of initial terms consider the diagram of A256249 in the fourth quadrant of the square grid together with a reflected copy in the second quadrant.
Also the third sequence of Betti numbers of the Lie algebra m_0(n) over Z_2. See the Nikolayevsky-Tsartsaflis paper, pages 2 and 6. Note that a(n) is denoted by b_3(m_0(n)).

Crossrefs

Cf. A006257 (Josephus problem), A256249, A266535, A266510, A266530, A266538, A266539.

Programs

Formula

a(2n-1) = A266535(n).
a(2n) = 2 * A256249(n-1) = A266538(n-1).
a(n) = (a(n-1) + a(n+1))/2, if n is an odd number greater than 1.
G.f.: (x^3+x^5)/(1-2*x+2*x^3-x^4) - x*(1-x)^(-2)*Sum_{k>=1} 2^k*x^(2^(1+k)). - Robert Israel, Jan 13 2016

A181281 A version of Josephus problem: a(n) is the surviving integer under the following elimination process. Arrange 1,2,3,...,n in a circle, increasing clockwise. Starting with i=1, delete the integer 4 places clockwise from i. Repeat, counting 4 places from the next undeleted integer, until only one integer remains.

Original entry on oeis.org

1, 2, 1, 2, 2, 1, 6, 3, 8, 3, 8, 1, 6, 11, 1, 6, 11, 16, 2, 7, 12, 17, 22, 3, 8, 13, 18, 23, 28, 3, 8, 13, 18, 23, 28, 33, 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 3, 8, 13, 18, 23, 28, 33, 38
Offset: 1

Views

Author

Paul Weisenhorn, Oct 10 2010

Keywords

Examples

			a(7) = 6: (^1,2,3,4,5,6,7) -> (1,2,3,4,^6,7) -> (1,2,^4,6,7) -> (1,^4,6,7) -> (1,^6,7) -> (^1,6) -> (^6).
a(14) = 11 => a(15) = (a(14)+4) mod 15 + 1 = 1.
		

References

  • Paul Weisenhorn, Josephus und seine Folgen, MNU Journal (Der mathematische und naturwissenschaftliche Unterricht), 59 (2006), 18-19.

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember;
          `if` (n=1, 1, (a(n-1)+4) mod n +1)
        end:
    seq (a(n), n=1..100);
  • Mathematica
    a[1] = 1; a[n_] := a[n] = Mod[a[n-1]+4, n]+1; Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Oct 18 2013 *)

Formula

a(n) = (a(n-1) + 4) mod n + 1 if n>1, a(1) = 1.

Extensions

Edited by Alois P. Heinz, Sep 06 2011

A198789 Array T(n,k) read by antidiagonals: Last survivor positions in Josephus problem for n numbers and a count of k, n >= 1, k >= 1.

Original entry on oeis.org

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

Views

Author

William Rex Marshall, Nov 21 2011

Keywords

Comments

Arrange 1, 2, 3, ..., n clockwise in a circle. Starting the count at 1, delete every k-th integer clockwise until only one remains, which is T(n,k).
The main diagonal (1, 1, 2, 2, 2, 4, 5, 4, ...) is A007495.
Concatenation of consecutive rows (up to the main diagonal) gives A032434.
The periods of the rows, (1, 2, 6, 12, 60, 60, 420, 840, ...), is given by A003418.

Examples

			.n\k  1  2  3  4  5  6  7  8  9 10
----------------------------------
.1 |  1  1  1  1  1  1  1  1  1  1
.2 |  2  1  2  1  2  1  2  1  2  1
.3 |  3  3  2  2  1  1  3  3  2  2
.4 |  4  1  1  2  2  3  2  3  3  4
.5 |  5  3  4  1  2  4  4  1  2  4
.6 |  6  5  1  5  1  4  5  3  5  2
.7 |  7  7  4  2  6  3  5  4  7  5
.8 |  8  1  7  6  3  1  4  4  8  7
.9 |  9  3  1  1  8  7  2  3  8  8
10 | 10  5  4  5  3  3  9  1  7  8
		

Crossrefs

Cf. A000027 (k = 1), A006257 (k = 2), A054995 (k = 3), A088333 (k = 4), A181281 (k = 5), A360268 (k = 6), A178853 (k = 7), A109630 (k = 8).
Cf. A003418, A007495 (main diagonal), A032434, A198788, A198790.

Programs

  • Mathematica
    T[n_, k_] := T[n, k] = If[n == 1, 1, Mod[T[n-1, k]+k-1, n]+1];
    Table[T[n-k+1, k], {n, 1, 13}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Mar 04 2023 *)

Formula

T(1,k) = 1; for n > 1: T(n,k) = ((T(n-1,k) + k - 1) mod n) + 1.

A345110 a(n) is n rotated one place to the left or, equivalently, n with the most significant digit moved to the least significant place, omitting leading zeros.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 6, 16, 26, 36, 46, 56, 66, 76, 86
Offset: 0

Views

Author

Felix Fröhlich, Jun 09 2021

Keywords

Comments

First differs from A004086 at n = 101, since A004086(101) = 101, but a(101) = 11.

Examples

			For n = 123: When 123 is rotated one place to the left the resulting number is 231, so a(123) = 231.
		

Crossrefs

Programs

  • Mathematica
    Array[FromDigits@*RotateLeft@*IntegerDigits,100,0] (* Giorgos Kalogeropoulos, Jun 09 2021 *)
  • PARI
    eva(n) = subst(Pol(n), x, 10)
    rot(vec) = if(#vec < 2, return(vec)); my(s=concat(Str(2), ".."), v=[]); s=concat(s, Str(#vec)); v=vecextract(vec, s); v=concat(v, vec[1]); v
    a(n) = eva(rot(digits(n)))
    
  • Python
    def rotl(s): return s[1:] + s[0]
    def a(n): return int(rotl(str(n)))
    print([a(n) for n in range(69)]) # Michael S. Branicky, Jun 09 2021

A375825 Triangle read by rows where row n is the Eytzinger array layout of n elements (a permutation of {1..n}).

Original entry on oeis.org

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

Views

Author

Darío Clavijo, Aug 30 2024

Keywords

Comments

The Eytzinger layout arranges elements of an array so that a binary search can be performed starting with index k = 1 and at a given k step to 2*k or 2*k+1, according to whether the target is smaller or larger than the element at k.
Row n is formed by: Take a binary search tree of n vertices which is a complete tree except for a possibly incomplete last row; number the vertices 1 to n by an in-order traversal; then read those vertex numbers row-wise (breadth first).

Examples

			Triangle begins:
   n  | k 1  2  3  4  5  6  7   8  9  10
  ---------------------------------------
   1  |   1
   2  |   2, 1
   3  |   2, 1, 3
   4  |   3, 2, 4, 1
   5  |   4, 2, 5, 1, 3
   6  |   4, 2, 6, 1, 3, 5
   7  |   4, 2, 6, 1, 3, 5, 7
   8  |   5, 3, 7, 2, 4, 6, 8,  1
   9  |   6, 4, 8, 2, 5, 7, 9,  1, 3
   10 |   7, 4, 9, 2, 6, 8, 10, 1, 3, 5
For n=10, the binary search tree numbered in-order is as follows and row 10 is by reading row-wise.
           7
         /   \
       4       9
     /  \     / \
    2    6   8   10
   /\   /
  1  3  5
		

Crossrefs

Cf. A000217 (row sums), A375544 (alternating row sums), A006257 (main diagonal, (central terms)/2), A006165 (col 1).
Cf. A368783 (rank), A370006 (SJT rank), A369802 (inversions).

Programs

  • Python
    def A375825row(n):
        row = [0] * (n + 1)
        def e_rec(j, i):
            if j <= n:
                i = e_rec(2 * j, i)
                row[j] = i
                i = e_rec(2 * j + 1, i + 1)
            return i
        e_rec(1, 1)
        return row

A088161 n rotated one binary place to the right less n rotated one binary place to the left.

Original entry on oeis.org

0, 0, 0, 0, 1, 3, -2, 0, 3, 9, 0, 6, -3, 3, -6, 0, 7, 21, 4, 18, 1, 15, -2, 12, -5, 9, -8, 6, -11, 3, -14, 0, 15, 45, 12, 42, 9, 39, 6, 36, 3, 33, 0, 30, -3, 27, -6, 24, -9, 21, -12, 18, -15, 15, -18, 12, -21, 9, -24, 6, -27, 3, -30, 0, 31, 93, 28, 90, 25, 87, 22, 84, 19, 81, 16, 78, 13, 75, 10, 72, 7, 69, 4
Offset: 0

Views

Author

Robert G. Wilson v, Sep 13 2003

Keywords

Comments

f(n) is negative about 2/7 of the time to 10^7. f(n) is zero, see A088163.

Crossrefs

Programs

  • Maple
    f:= proc(n) local a,b;
      if n::even then a:= n/2 else a:= 2^ilog2(n) + (n-1)/2 fi;
      if n = 0 then b:= 0 else b:= 2*n + 1 - 2^(ilog2(n)+1) fi;
      a-b
    end proc:
    map(f, [$0..200]); # Robert Israel, Mar 03 2025
  • Mathematica
    f[n_] := FromDigits[ RotateRight[ IntegerDigits[n, 2]], 2] - FromDigits[ RotateLeft[ IntegerDigits[n, 2]], 2]; Table[ f[n], {n, 0, 82}]

Formula

a(n) = A038572(n) - A006257(n).

A291317 A variation of the Josephus problem: a(n) is the surviving integer under the following elimination process. Arrange 1,2,3,...,n in a circle, increasing clockwise. Starting with i=1, at k-th stage, move k places clockwise and delete the current number.

Original entry on oeis.org

1, 1, 1, 3, 4, 3, 7, 7, 6, 10, 7, 12, 3, 10, 11, 7, 11, 1, 12, 6, 21, 1, 7, 12, 25, 3, 25, 28, 16, 26, 25, 6, 32, 19, 15, 21, 28, 3, 12, 21, 24, 13, 21, 36, 17, 45, 41, 45, 8, 40, 11, 6, 25, 41, 23, 4, 43, 52, 51, 57, 28, 21, 11, 47, 26, 29, 57, 51, 48, 56, 12
Offset: 1

Views

Author

Rémy Sigrist, Aug 22 2017

Keywords

Comments

In the classical Josephus problem (A006257), one moves one place clockwise at each stage, and in the A054995 version, one moves two places clockwise at each stage; here, on the other hand, the number of moves is progressive, and the resulting sequence seems random.
No term belongs to A000096 (for the same reason that there are no even positive terms in A006257).
See also A128982 for another variation of the Josephus problem.
a(n) = 1 for n = 1, 2, 3, 18, 22, 171, 195, 234, 1262, 2136, ...
a(n) = n for n = 1, 7, 10, 12, 21, 25, 28, 235, 822, ...
More formally, for any function f over the natural numbers, let us define the function j_f with these rules: for any n > 0:
- let L = (1, 2, ..., n) be the list of the first n natural numbers,
- for k = 1 to n-1:
- for i = 1 to f(k): move the first element of L to the end,
- after these moves, discard the first element of L,
- j_f(n) = the remaining element in L.
In particular:
- and j_A000027 = a (this sequence),
- see also Links section for the scatterplots of j_f for certain classical or basic functions f.
We have the following properties:
- j_f(1) = 1,
- if f(1) = 1 mod 2 then j_f(2) = 1 else j_f(2) = 2,
- j_f(n) never equals k + Sum_{i=1..k} f(i),
- iterating j_f(n), j_f(j_f(n)), ... eventually leads to a fixed point,
- likely j_f = j_g iff f = g.

Examples

			The different stages for n=6 are (where ^ indicates the counting reference position):
- stage 1:  1^ 2  3  4  5  6
- stage 2:  1     3^ 4  5  6
- stage 3:  1     3  4     6^
- stage 4:  1     3        6^
- stage 5:        3^       6
- stage 6:        3^
Hence, a(6) = 3.
		

Crossrefs

Programs

  • PARI
    a(n) = my (l = List(vector(n,i,i)), i = 0); for (k = 1, n-1, i += k; my (p = i \ #l); listpop(l, 1 + (i % #l)); i -= p); return (l[1])

A337191 A version of the Josephus problem: a(n) is the surviving integer under the skip-eliminate-eliminate version of the elimination process.

Original entry on oeis.org

1, 1, 1, 4, 4, 1, 7, 4, 1, 7, 4, 10, 7, 13, 10, 16, 13, 1, 16, 4, 19, 7, 22, 10, 25, 13, 1, 16, 4, 19, 7, 22, 10, 25, 13, 28, 16, 31, 19, 34, 22, 37, 25, 40, 28, 43, 31, 46, 34, 49, 37, 52, 40, 1, 43, 4, 46, 7, 49, 10, 52, 13, 55, 16, 58, 19, 61, 22, 64, 25, 67
Offset: 1

Views

Author

Robert W. Vallin, Aug 18 2020

Keywords

Comments

This variation of the Josephus problem is related to under-down-down card dealing. - Tanya Khovanova, Apr 14 2025

Examples

			Consider 4 people in a circle in order 1,2,3,4. In the first round, person 1 is skipped and persons 2 and 3 are eliminated. Now people are in order 4,1. In the second round, person 4 is skipped and person 1 is eliminated. Person 4 is freed. Thus, a(4) = 4. - _Tanya Khovanova_, Apr 14 2025
		

Crossrefs

Programs

  • Mathematica
    nxt[{n_,a_,b_}]:={n+1,b,If[Mod[a+3,n+1]!=0,Mod[a+3,n+1],n+1]}; NestList[nxt,{2,1,1},70][[;;,2]] (* Harvey P. Dale, Jul 27 2024 *)
  • PARI
    a(n) = if (n <= 2, 1, my(x = (a(n-2) + 3) % n); if (x, x, n)); \\ Michel Marcus, Aug 20 2020
    
  • PARI
    a(n) = if (n<=1, return(1)); my(v=vector(n, i, i), w); while (#v > 3, if (#v <=3, w = [], w = vector(#v-3, k, v[k+3])); w = concat(w, Vec(v, 1)); v = w;); v[1]; \\ Michel Marcus, Mar 25 2025

Formula

a(1) = 1, a(2) = 1, a(n) = (a(n-2) + 3) (mod n) if (a(n-2) + 3) (mod n) is not 0; a(n) = n if (a(n-2) + 3) (mod n)=0.
Any number n can be written as either 2*(3^k) + 2m (where 0 <= m < 3^k, k = 0,1,2,...) or 3^k + 2m (where 0 <= m < 3^k, k = 0,1,2,...), in either case a(n) = 3m + 1.

Extensions

More terms from Michel Marcus, Aug 20 2020
Title corrected by Tanya Khovanova, Apr 14 2025

A381050 Triangle T(n,k) read by rows, where row n is a permutation of the numbers 1 through n, such that if a deck of n cards is prepared in this order, and down-under-down dealing is used, then the resulting cards will be dealt in increasing order.

Original entry on oeis.org

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

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Apr 14 2025

Keywords

Comments

Down-under-down dealing is a dealing pattern where the top card is dealt, the second card is placed at the bottom of the deck, then the third card is dealt. This pattern repeats until all of the cards have been dealt.
This card dealing is related to a variation on the Josephus problem, where the first person is eliminated, the second person is skipped, and the third person is eliminated. The card in row n and column k is x if and only if in the corresponding Josephus problem with n people, the person number x is the k-th person eliminated. Equivalently, each row of Josephus triangle A383076 is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is A032766(n) = floor(3n/2).
The index of the largest number in row n is A381051(n), corresponding to the index of the freed person in the corresponding Josephus problem.

Examples

			Consider a deck of four cards arranged in the order 1,4,2,3. In round 1, card 1 is dealt, card 4 goes under, card 2 is dealt. Now the deck is ordered 3,4. In round 2, card 3 is dealt, card 4 goes under, then card 4 is dealt. The dealt cards are in order. Thus, the fourth row of the triangle is 1,4,2,3.
Table begins:
  1;
  1, 2;
  1, 3, 2;
  1, 4, 2, 3;
  1, 4, 2, 3, 5;
  1, 5, 2, 3, 6, 4;
  1, 7, 2, 3, 6, 4, 5;
  1, 6, 2, 3, 7, 4, 5, 8;
		

Crossrefs

Programs

  • Mathematica
    row[n_]:=Module[{ds,res,k,i=1,len},ds=CreateDataStructure["Queue",Range[n]];res=CreateDataStructure["FixedArray",n];While[(ds["Length"]>=2),res["SetPart",i++,ds["Pop"]];ds["Push",ds["Pop"]];If[ds["Length"]>1,res["SetPart",i++,ds["Pop"]];]];res["SetPart",n,ds["Pop"]];Flatten[PositionIndex[res["Elements"]]/@Range[n]]];
    Array[row, 13, 1] // Flatten (* Shenghui Yang, May 11 2025 *)
  • Python
    def row(n):
        i, J, out = 0, list(range(1, n+1)), []
        while len(J) > 1:
            i = i%len(J)
            out.append(J.pop(i))
            i = (i + 1)%len(J)
            #i = i%len(J)
            if len(J) > 1:
                out.append(J.pop(i))
        out += [J[0]]
        return [out.index(j)+1 for j in list(range(1, n+1))]
    print([e for n in range(1, 14) for e in row(n)]) # Michael S. Branicky, Apr 28 2025

Formula

T(n,3j) = 2j, for 3j <= n. T(n,3j+1) = 2j+1, for 3j+1 <= n.

A049885 a(n) = a(1) + a(2) + ... + a(n-1) - a(m) for n >= 4, where m = 2^(p+1) + 2 - n and p is the unique integer such that 2^p < n - 1 <= 2^(p+1), starting with a(1) = a(2) = a(3) = 1.

Original entry on oeis.org

1, 1, 1, 2, 4, 7, 15, 30, 60, 91, 197, 402, 807, 1616, 3233, 6466, 12932, 19399, 42031, 85679, 172167, 344739, 689683, 1379472, 2758975, 5517980, 11035975, 22071958, 44143919, 88287840, 176575681, 353151362, 706302724, 1059454087
Offset: 1

Views

Author

Keywords

Examples

			From _Petros Hadjicostas_, Nov 07 2019: (Start)
a(4) = -a(2^ceiling(log_2(4-1)) + 2 - 4) + a(1) + a(2) + a(3) = -a(2) + a(1) + a(2) + a(3) = 2.
a(5) = -a(2^ceiling(log_2(5-1)) + 2 - 5) + a(1) + a(2) + a(3) + a(4) = -a(1) + a(1) + a(2) + a(3) + a(4) = 4.
a(6) = -a(2^ceiling(log_2(6-1)) + 2 - 6) + a(1) + a(2) + a(3) + a(4) + a(5) = -a(4) + a(1) + a(2) + a(3) + a(4) + a(5) = 7.
a(7) =  -a(7 - 1 - A006257(7-2)) + Sum_{i = 1..6} a(i) = -a(3) +  Sum_{i = 1..6} a(i) = 15.
a(8) =  -a(8 - 1 - A006257(8-2)) + Sum_{i = 1..7} a(i) = -a(2) +  Sum_{i = 1..7} a(i) = 30. (End)
		

Crossrefs

Cf. A006257, A049933 (similar, but with plus a(m)).

Programs

  • Maple
    s := proc(n) option remember; `if`(n < 1, 0, a(n) + s(n - 1)) end proc:
    a := proc(n) option remember;
    `if`(n < 4, 1, s(n - 1) - a(Bits:-Iff(n - 2, n - 2) + 3 - n)):
    end proc:
    seq(a(n), n = 1..34); # Petros Hadjicostas, Nov 07 2019
  • PARI
    lista(nn) = { my(va = vector(nn)); va[1] = 1; va[2] = 1; va[3] = 1; my(sa = vecsum(va)); for (n=4, nn, va[n] = sa - va[2 - n + 2^ceil(log(n-1)/log(2))]; sa += va[n]; ); va; } \\ Petros Hadjicostas, Apr 27 2020 (with nn > 2)

Formula

From Petros Hadjicostas, Nov 07 2019: (Start)
a(n) = -a(2^ceiling(log_2(n-1)) + 2 - n) + Sum_{i = 1..n-1} a(i) for n >= 4.
a(n) = -a(n - 1 - A006257(n-2)) + Sum_{i = 1..n-1} a(i) for n >= 4. (End)

Extensions

Name edited by Petros Hadjicostas, Nov 07 2019
Previous Showing 51-60 of 137 results. Next