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-10 of 39 results. Next

A025480 a(2n) = n, a(2n+1) = a(n).

Original entry on oeis.org

0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2, 10, 5, 11, 1, 12, 6, 13, 3, 14, 7, 15, 0, 16, 8, 17, 4, 18, 9, 19, 2, 20, 10, 21, 5, 22, 11, 23, 1, 24, 12, 25, 6, 26, 13, 27, 3, 28, 14, 29, 7, 30, 15, 31, 0, 32, 16, 33, 8, 34, 17, 35, 4, 36, 18, 37, 9, 38, 19, 39, 2, 40, 20, 41, 10
Offset: 0

Views

Author

Keywords

Comments

These are the Grundy values or nim-values for heaps of n beans in the game where you're allowed to take up to half of the beans in a heap. - R. K. Guy, Mar 30 2006. See Levine 2004/2006 for more about this. - N. J. A. Sloane, Aug 14 2016
When n > 0 is written as (2k+1)*2^j then k = a(n-1) and j = A007814(n), so: when n is written as (2k+1)*2^j-1 then k = a(n) and j = A007814(n+1), when n > 1 is written as (2k+1)*2^j+1 then k = a(n-2) and j = A007814(n-1). - Henry Bottomley, Mar 02 2000 [sequence id corrected by Peter Munn, Jun 22 2022]
According to the comment from Deuard Worthen (see Example section), this may be regarded as a triangle where row r=1,2,3,... has length 2^(r-1) and values T(r,2k-1)=T(r-1,k), T(r,2k)=2^(r-1)+k-1; i.e., previous row gives 1st, 3rd, 5th, ... term and 2nd, 4th, ... terms are numbers 2^(r-1),...,2^r-1 (i.e., those following the last one from the previous row). - M. F. Hasler, May 03 2008
Let StB be a Stern-Brocot tree hanging between (pseudo)fractions Left and Right, then StB(1) = mediant(Left,Right) and for n>1: StB(n) = if a(n-1)<>0 and a(n)<>0 then mediant(StB(a(n-1)),StB(a(n))) else if a(n)=0 then mediant(StB(a(n-1)),Right) else mediant(Left,StB(a(n-1))), where mediant(q1,q2) = ((numerator(q1)+numerator(q2)) / (denominator(q1)+denominator(q2))). - Reinhard Zumkeller, Dec 22 2008
This sequence is the unique fixed point of the function (a(0), a(1), a(2), ...) |--> (0, a(0), 1, a(1), 2, a(2), ...) which interleaves the nonnegative integers between the elements of a sequence. - Cale Gibbard (cgibbard(AT)gmail.com), Nov 18 2009
Also the number of remaining survivors in a Josephus problem after the person originally first in line has been eliminated (see A225381). - Marcus Hedbring, May 18 2013
A fractal sequence - see Levine 2004/2006. - N. J. A. Sloane, Aug 14 2016
From David James Sycamore, Apr 29 2020: (Start)
One of a family of fractal sequences, S_k; defined as follows for k >= 2: a(k*n) = n, a(k*n+r) = a((k-1)*n + (r-1)), r = 1..(k-1). S_2 is A025480; S_3 gives: a(3*n) = n, a(3*n + 1) = a(2*n), a(3*n + 2) = a(2*n + 1), which is A263390.
The subsequence of all nonzero terms is A131987. (End)
Similar to but different from A108202. - N. J. A. Sloane, Nov 26 2020
This sequence can be otherwise defined in two alternative (but related) ways, with a(0)=0, as follows: (i) If a(n) is a novel term, then a(n+1) = a(a(n)); if a(n) has been seen before, most recently at a(m), then a(n+1) = n-m (as in A181391). (ii) As above for novel a(n), then if a(n) has been seen before, a(n+1) = smallest k < a(n) which is not already a term. - David James Sycamore, Jul 13 2021
From a binary perspective, the sequence can be seen as even,odd pairs where the odd value is the previous even value, dropping the rightmost bits up to and including the lowest zero bit, aka right-shifted past the lowest clear bit. E.g., (5)101 -> 1, (17)10001 -> (4)100, (29)11101 -> (7)111, (39)100111 -> (2)10. - Joe Nellis, Oct 09 2022

Examples

			From Deuard Worthen (deuard(AT)raytheon.com), Jan 27 2006: (Start)
The sequence can be constructed as a triangle as:
  0
  0  1
  0  2  1  3
  0  4  2  5  1  6  3  7
  0  8  4  9  2 10  5 11  1 12  6 13  3 14  7 15
  ...
At each stage we interleave the next 2^m numbers in the previous row. (End)
Left=0/1, Right=1/0: StB=A007305/A047679; Left=0/1, Right=1/1: StB=A007305/A007306; Left=1/3, Right=2/3: StB=A153161/A153162. - _Reinhard Zumkeller_, Dec 22 2008
		

References

  • L. Levine, Fractal sequences and restricted Nim, Ars Combin. 80 (2006), 113-127.

Crossrefs

Programs

  • Haskell
    import Data.List
    interleave xs ys = concat . transpose $ [xs,ys]
    a025480 = interleave [0..] a025480
    -- Cale Gibbard, Nov 18 2009
    
  • Haskell
    Cf. comments by Worthen and Hasler.
    import Data.List (transpose)
    a025480 n k = a025480_tabf !! n !! k
    a025480_row n = a025480_tabf !! n
    a025480_tabf = iterate (\xs -> concat $
       transpose [xs, [length xs .. 2 * length xs - 1]]) [0]
    a025480_list = concat $ a025480_tabf
    -- Reinhard Zumkeller, Apr 29 2012
    
  • Maple
    A025480 := proc(n)
        option remember ;
        if type(n,'even') then
            n/2 ;
        else
            procname((n-1)/2) ;
        end if;
    end proc:
    seq(A025480(n),n=0..100) ; # R. J. Mathar, Jul 16 2020
  • Mathematica
    a[n_] := a[n] = If[OddQ@n, a[(n - 1)/2], n/2]; Table[ a[n], {n, 0, 83}] (* Robert G. Wilson v, Mar 30 2006 *)
    Table[BitShiftRight[n, IntegerExponent[n, 2] + 1], {n, 100}] (* IWABUCHI Yu(u)ki, Oct 13 2012 *)
  • PARI
    a(n)={while(n%2,n\=2);n\2} \\ M. F. Hasler, May 03 2008
    
  • PARI
    A025480(n)=n>>valuation(n*2+2,2) \\ M. F. Hasler, Apr 12 2012
    
  • Python
    def A025480(n): return n>>((~(n+1)&n).bit_length()+1) # Chai Wah Wu, Jul 13 2022
  • Sage
    A025480 = lambda n: odd_part(n+1)//2
    [A025480(n) for n in (0..83)] # Peter Luschny, May 20 2014
    

Formula

a(n) = A003602(n+1) - 1. [Corrected by Max Alekseyev, May 05 2022]
a(n) = (A000265(n+1)-1)/2 = ((n+1)/A006519(n+1)-1)/2.
a(n) = A153733(n)/2. - Reinhard Zumkeller, Dec 31 2008
2^A007814(n+1)*(2*a(n)+1) = n+1. (See functions hd, tl and cons in [Paul Tarau 2009].) - Paul Tarau (paul.tarau(AT)gmail.com), Mar 21 2010
a(3*n + 1) = A173732(n). - Reinhard Zumkeller, Apr 29 2012
a((2*n+1)*2^p-1) = n, p >= 0 and n >= 0. - Johannes W. Meijer, Jan 24 2013
a(n) = n - A225381(n). - Marcus Hedbring, May 18 2013
G.f.: -1/(1-x) + Sum_{k>=0} x^(2^k-1)/(1-2*x^2^(k+1)+x^2^(k+2)). - Ralf Stephan, May 19 2013
a(n) = A049084(A181363(n+1)). - Reinhard Zumkeller, Mar 22 2014
a(n) = floor(n / 2^A001511(n+1)). - Adam Shelly, Mar 05 2019
Recursion: a(0) = 0; a(n + 1) = a(a(n)) if a(n) is a first occurrence of a term, else a(n + 1) = n - a(n-1). - David James Sycamore, Apr 29 2020
a(n) * 2^(A007814(n+1)+1) + 2^A007814(n+1) - 1 = n (equivalent to the formula given in the comment by Paul Tarau). - Ruud H.G. van Tol, Apr 14 2023
Sum_{k=1..n} a(k) = n^2/6 + O(n). - Amiram Eldar, Aug 07 2023

Extensions

Edited by M. F. Hasler, Mar 16 2018

A321298 Triangle read by rows: T(n,k) is the number of the k-th eliminated person in the Josephus elimination process for n people and a count of 2, 1 <= k <= n.

Original entry on oeis.org

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

Views

Author

Zeph L. Turner, Nov 02 2018

Keywords

Comments

In the Josephus elimination process for n and k, the numbers 1 through n are written in a circle. A pointer starts at position 1. Each turn, the pointer skips (k-1) non-eliminated number(s) going around the circle and eliminates the k-th number, until no numbers remain. This sequence represents the triangle J(n, i), where n is the number of people in the circle, i is the turn number, and k is fixed at 2 (every other number is eliminated).

Examples

			Triangle begins:
  1;
  2, 1;
  2, 1, 3;
  2, 4, 3, 1;
  2, 4, 1, 5,  3;
  2, 4, 6, 3,  1,  5;
  2, 4, 6, 1,  5,  3, 7;
  2, 4, 6, 8,  3,  7, 5, 1;
  2, 4, 6, 8,  1,  5, 9, 7,  3;
  2, 4, 6, 8, 10,  3, 7, 1,  9,  5;
  2, 4, 6, 8, 10,  1, 5, 9,  3, 11, 7;
  2, 4, 6, 8, 10, 12, 3, 7, 11,  5, 1, 9;
  2, 4, 6, 8, 10, 12, 1, 5,  9, 13, 7, 3, 11;
  ...
For n = 5, to get the entries in 5th row from left to right, start with (^1, 2, 3, 4, 5) and the pointer at position 1, indicated by the caret. 1 is skipped and 2 is eliminated to get (1, ^3, 4, 5). (The pointer moves ahead to the next "live" number.) On the next turn, 3 is skipped and 4 is eliminated to get (1, 3, ^5). Then 1, 5, and 3 are eliminated in that order (going through (^3, 5) and (^3)). This gives row 5 of the triangle and entries a(11) through a(15) in this sequence.
		

Crossrefs

The right border of this triangle is A006257.
Cf. A032434, A054995, A181281, A225381, A378635 (row permutation inverses).

Programs

  • Mathematica
    Table[Rest@ Nest[Append[#1, {Delete[#2, #3 + 1], #2[[#3 + 1]], #3}] & @@ {#, #[[-1, 1]], Mod[#[[-1, -1]] + 1, Length@ #[[-1, 1]]]} &, {{Range@ n, 0, 0}}, n][[All, 2]], {n, 14}] // Flatten (* Michael De Vlieger, Nov 13 2018 *)
  • Python
    def A321298(n,k):
        if 2*k<=n: return 2*k
        n2,r=divmod(n,2)
        if r==0: return 2*A321298(n2,k-n2)-1
        if k==n2+1: return 1
        return 2*A321298(n2,k-n2-1)+1 # Pontus von Brömssen, Sep 18 2022

Formula

From Pontus von Brömssen, Sep 18 2022: (Start)
The terms are uniquely determined by the following recursive formulas:
T(n,k) = 2*k if k <= n/2;
T(2*n,k) = 2*T(n,k-n)-1 if k > n;
T(2*n+1,k) = 2*T(n,k-n-1)+1 if k > n+1;
T(2*n+1,n+1) = 1.
(End)
From Pontus von Brömssen, Dec 11 2024: (Start)
The terms are also uniquely determined by the following recursive formulas:
T(1,1) = 1;
T(n,1) = 2 if n > 1;
T(n,k) = T(n-1,k-1)+2 if k > 1 and T(n-1,k-1) != n-1;
T(n,k) = 1 if k > 1 and T(n-1,k-1) = n-1.
T(n,A225381(n)) = 1.
T(n,A225381(n+1)-1) = n.
(End)

Extensions

Name clarified by Pontus von Brömssen, Sep 18 2022

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

Original entry on oeis.org

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

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Dec 02 2024

Keywords

Comments

Under-down dealing is a dealing pattern where the top card is put on the bottom of the deck, and the next card is dealt. Then, this pattern repeats until all cards are dealt.
This card dealing is related to the Josephus problem. The card in row n and column k is x if and only if in the Josephus problem with n people, the person number x is the k-th person eliminated. Equivalently, each row of Josephus triangle A321298 is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is 2n.
The first column is A225381, the order of elimination of the first person in the Josephus problem.
The index of the largest number in row n is A006257(n), corresponding to the index of the freed person in the Josephus problem.
T(n,2j) = j, for 2j <= n.

Examples

			Suppose there are four cards arranged in order 4,1,3,2. Card 4 goes under, and card 1 is dealt. Now the deck is ordered 3,2,4. Card 3 goes under, and card 2 is dealt. Now the leftover deck is ordered 4,3. Card 4 goes under, and card 3 is dealt. Then card 4 goes under, and card 4 is dealt. The dealt cards are in order. Thus, the fourth row of the triangle is 4,1,3,2.
Triangle begins:
  1;
  2, 1;
  2, 1, 3;
  4, 1, 3, 2;
  3, 1, 5, 2, 4;
  5, 1, 4, 2, 6, 3;
  4, 1, 6, 2, 5, 3, 7;
  8, 1, 5, 2, 7, 3, 6, 4;
  5, 1, 9, 2, 6, 3, 8, 4, 7;
		

Crossrefs

Formula

T(1,1) = 1, for n > 1, T(n,1) = T(n-1,n-1) + 1 and T(n,2) = 1. For n > 1 and k > 2, T(n,k) = T(n-1,k-2) + 1.

A380201 Triangle T(n,k) read by rows, where row n is a permutation of numbers 1 through n, such that if a deck of n cards is prepared in this order, and SpellUnder-Down dealing is used, then the resulting cards are put down in increasing order.

Original entry on oeis.org

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

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Jan 16 2025

Keywords

Comments

In Spell Under-Down dealing, we spell the positive integers starting from O-N-E, moving 1 card from the top of the deck underneath the deck for each letter, followed by dealing or "putting down" the top card. So we start by putting 3 cards under for O-N-E, then we deal a card. Then we put 3 cards under for T-W-O, then we deal a card. Then we put 5 cards under for T-H-R-E-E, and subsequently deal a card. This dealing sequence is highly irregular because it depends on English spelling. The dealing pattern starts: UUUDUUUDUUUUUD, where each "U" corresponds to putting a card “under” and each "D" corresponds to dealing a card “down”.
This card dealing can be thought of as a generalized version of the Josephus problem. In this version of the Josephus problem, we spell the positive integers in increasing order, each time skipping past 1 person for each letter and executing the next person. The card in row n and column k is x if and only if in the corresponding Josephus problem with n people, the person numbered x is the k-th person eliminated.
Equivalently, each row of the corresponding Josephus triangle A380247 is an inverse permutation of the corresponding row of this triangle. The first column is A380246, the order of elimination of the first person in the corresponding Josephus problem. The index of the largest number in row n is A380204(n), corresponding to the index of the freed person in the corresponding Josephus problem. The number of card moves if we start with n cards is A380202 = A067278(n) + n.

Examples

			Triangle begins:
  1;
  2, 1;
  1, 3, 2;
  2, 4, 3, 1;
  5, 3, 2, 1, 4;
  4, 2, 5, 1, 3, 6;
  2, 3, 4, 1, 6, 5, 7;
  5, 6, 8, 1, 7, 4, 3, 2;
  ...
For n = 4 suppose there are four cards arranged in order 2, 4, 3, 1. Three cards go under for each letter in O-N-E, then 1 is dealt. Now the deck is ordered 2,4,3. Three cards go under for each letter in T-W-O, then card 2 is dealt. Now the leftover deck is ordered 4,3. Five cards go under for each letter in T-H-R-E-E, then card 3 is dealt. Finally, card 4 is dealt. The dealt cards are in numerical order. Thus, the fourth row of the triangle is 2, 4, 3, 1.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def spell(n):
        return sum(1 for c in n2w(n).replace(" and", "").replace(" ", "").replace(",","").replace("-", ""))
    def nthRow(n):
        l = []
        for i in range(0,n):
            l.append(0)
        zp = 0
        for j in range(1,n+1):
            zc = 0
            while zc <= spell(j):
                if l[zp] == 0:
                    zc += 1
                zp += 1
                zp = zp % n
            l[zp-1] = str(j)
        return l
    l = []
    for i in range(1,20):
        l += nthRow(i)
    print(", ".join(l))

A380204 A version of the Josephus problem: a(n) is the surviving integer under the spelling version of the elimination process.

Original entry on oeis.org

1, 1, 2, 2, 1, 6, 7, 3, 5, 3, 5, 6, 10, 9, 2, 13, 3, 16, 10, 2, 15, 6, 15, 6, 21, 1, 7, 23, 26, 6, 20, 12, 27, 29, 7, 2, 36, 11, 6, 7, 32, 6, 32, 43, 10, 31, 7, 5, 42, 1, 17, 48, 7, 31, 53, 25, 42, 43, 29, 39, 51, 25, 43, 7, 26, 59, 15, 10, 60, 69, 13, 57, 54, 66, 57, 30, 9, 35, 64, 9, 65, 1, 15, 3, 79, 47, 86, 7
Offset: 1

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Jan 16 2025

Keywords

Comments

Arrange n people numbered 1, 2, 3, ..., n in a circle, increasing clockwise. Starting with the person numbered 1, spell the letters of O-N-E, moving one person clockwise for each letter. Once you are done, eliminate the next person. Then, spell the letters of T-W-O; in other words, skip three people and eliminate the next person. Following this, spell the letters of T-H-R-E-E; in other words, skip five people and eliminate the next person. Continue until one person remains. The number of this person is a(n).

Examples

			Consider n = 4 people. The first person eliminated is number 4. This leaves the remaining people in the order 1, 2, 3. The second person eliminated is number 1; the people left are in the order 2, 3. The next person eliminated is numbered 3, leaving only the person numbered 2. Thus a(4) = 2.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def f(n): return sum(1 for c in n2w(n).replace(" and", "") if c.isalpha())
    def a(n):
        c, i, J = 1, 0, list(range(1, n+1))
        while len(J) > 1:
            i = (i + f(c))%len(J)
            q = J.pop(i)
            c = c+1
        return J[0]
    print([a(n) for n in range(1, 89)]) # Michael S. Branicky, Jan 26 2025

Extensions

Terms a(22) and beyond corrected by Michael S. Branicky, Feb 15 2025

A380246 Elimination order of the first person in a variation of the Josephus problem, where the number of skipped people correspond to the number of letters in consecutive numbers, called SpellUnder-Down.

Original entry on oeis.org

1, 2, 1, 2, 5, 4, 2, 5, 6, 4, 6, 10, 3, 12, 6, 8, 15, 4, 13, 19, 14, 17, 5, 22, 18, 26, 6, 20, 13, 17, 19, 23, 7, 25, 21, 31, 22, 32, 8, 31, 38, 20, 29, 9, 27, 18, 43, 10, 15, 50, 37, 20, 16, 41, 11, 21, 39, 36, 34, 32, 29, 12, 36, 50, 27, 53, 35, 19, 45, 67, 13, 20, 70, 59, 74, 26, 21, 40, 65, 14, 49, 82, 33, 43, 28, 34, 53, 15
Offset: 1

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Jan 17 2025

Keywords

Comments

Arrange n people numbered 1,2,3,...,n in a circle, increasing clockwise. Starting with the person numbered 1, spell the letters of O-N-E, moving one person clockwise for each letter. Once you are done, eliminate the next person. Then, spell the letters of T-W-O; in other words, skip three people and eliminate the next person. Following this, spell the letters of T-H-R-E-E; in other words, skip five people and eliminate the next person. Continue until one person remains. a(n) is the order of elimination of the first person.

Examples

			Consider n = 4 people. The first person eliminated is number 4. This leaves the remaining people in order 1, 2, 3. The second person eliminated is number 1. Thus, person number 1 is eliminated in the second round, implying that a(4) = 2.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def spell(n):
        return sum(1 for c in n2w(n).replace(" and", "").replace(" ", "").replace(chr(44), "").replace("-", ""))
    def nthRow(n):
        l = []
        for i in range(0,n):
            l.append(0)
        zp = 0
        for j in range(1,n+1):
            zc = 0
            while zc <= spell(j):
                if l[zp] == 0:
                    zc += 1
                zp += 1
                zp = zp % n
            l[zp-1] = str(j)
        return l
    l = []
    for i in range(1,89):
        l += [nthRow(i)[0]]
    print(l)
    
  • Python
    from num2words import num2words as n2w
    def f(n): return sum(1 for c in n2w(n).replace(" and", "") if c.isalpha())
    def a(n):
        c, i, J = 1, 0, list(range(1, n+1))
        while len(J) > 0:
            i = (i + f(c))%len(J)
            q = J.pop(i)
            if q == 1: return c
            c = c+1
    print([a(n) for n in range(1, 89)]) # Michael S. Branicky, Feb 15 2025

A380202 Number of card moves to deal n cards using the SpellUnder-Down dealing.

Original entry on oeis.org

4, 8, 14, 19, 24, 28, 34, 40, 45, 49, 56, 63, 72, 81, 89, 97, 107, 116, 125, 136, 146, 156, 168, 179, 190, 200, 212, 224, 235, 246, 256, 266, 278, 289, 300, 310, 322, 334, 345, 355, 364, 373, 384, 394, 404, 413, 424, 435, 445, 455, 464, 473, 484, 494, 504, 513, 524, 535, 545, 555, 564, 573, 584, 594, 604, 613, 624, 635, 645
Offset: 1

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Jan 16 2025

Keywords

Comments

In SpellUnder-Down dealing, we spell the number of the next card, putting a card under for each letter in the number, then we deal the next card. So we start with putting 3 cards under, for O-N-E, then deal, then 3 under for T-W-O, then deal, then 5 under for T-H-R-E-E, then deal. The dealing sequence is highly irregular because it depends on English spelling. The dealing pattern starts: UUUDUUUDUUUUUD.

Examples

			The dealing pattern to deal three cards is UUUDUUUDUUUUUD. It contains 14 letters, thus, a(3) = 14.
		

Crossrefs

Formula

a(n) = A067278(n) + n.

A380247 Triangle read by rows: T(n,k) is the number of the k-th eliminated person in the variation of the Josephus elimination process for n people, where the number of people skipped correspond to the number of letters in the next number in English alphabet.

Original entry on oeis.org

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

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Jan 17 2025

Keywords

Comments

In this variation of the Josephus elimination process, the numbers 1 through n are arranged in a circle. A pointer starts at position 1. Then three people are skipped because number O-N-E has three letters, then the next person is eliminated. Next, three people are skipped because T-W-O has three letters, and the next person is eliminated. Then, five people are skipped because T-H-R-E-E has five letters, and so on. This repeats until no numbers remain. This sequence represents the triangle T(n, k), where n is the number of people in the circle, and T(n, k) is the elimination order of the k-th person in the circle.
In rows 4 and after, the first number is 4. In rows 8 and after, the second number is 8. In rows 14 and after, the third number is 14. In the limit the numbers form sequence A380202.

Examples

			Triangle begins:
  1;
  2, 1;
  1, 3, 2;
  4, 1, 3, 2;
  4, 3, 2, 5, 1;
  4, 2, 5, 1, 3, 6;
  4, 1, 2, 3, 6, 5, 7;
  ...
For n = 4 suppose four people are arranged in a circle corresponding to the fourth row of the triangle. Three people are skipped for each letter in O-N-E; then the 4th person is eliminated. This means the row starts with 4. The next three people are skipped, and the person eliminated is number 1. Thus, the next element in the row is 1. Then, 5 people are skipped, and the next person eliminated is number 3. Similarly, the last person eliminated is number 2. Thus, the fourth row of this triangle is 4, 1, 3, 2.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def spell(n):
        return sum(1 for c in n2w(n).replace(" and", "").replace(" ", "").replace(chr(44), "").replace("-", ""))
    def inverse_permutation(p):
        inv = [0] * len(p)
        for i, x in enumerate(p):
            inv[x-1] = i +1
        return inv
    def nthRow(n):
        l = []
        for i in range(0,n):
            l.append(0)
        zp = 0
        for j in range(1,n+1):
            zc = 0
            while zc <= spell(j):
                if l[zp] == 0:
                    zc += 1
                zp += 1
                zp = zp % n
            l[zp-1] = j
        return l
    l = []
    for i in range(1,15):
        l += inverse_permutation(nthRow(i))
    print(l)
    
  • Python
    from num2words import num2words as n2w
    def f(n): return sum(1 for c in n2w(n).replace(" and", "") if c.isalpha())
    def row(n):
        c, i, J = 1, 0, list(range(1, n+1))
        out = []
        while len(J) > 1:
            i = (i + f(c))%len(J)
            q = J.pop(i)
            out.append(q)
            c = c+1
        out.append(J[0])
        return out
    print([e for n in range(1, 15) for e in row(n)]) # Michael S. Branicky, Feb 15 2025

A380248 The order of the 13 cards of one suit such that after the SpellUnder-Down deal the cards are in order; a(n) is the n-th card in the deck.

Original entry on oeis.org

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

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Jan 17 2025

Keywords

Comments

Number 1 corresponds to ace, 11 to jack, 12 to queen, 13 to king.
In the SpellUnder-Down deal, we spell the next card, putting a card under for each letter in the name, then we deal the next card. So we start with putting 3 cards under for A-C-E, then deal, then 3 cards under for T-W-O, then deal, then 5 cards under for T-H-R-E-E, then deal. The dealing sequence is highly irregular because it depends on English spelling. The dealing pattern starts: UUUDUUUDUUUUUD.
The sequence is a permutation of 13 numbers.

Examples

			The first card dealt is the fourth card in the deck, thus, the fourth card must be an ace.
		

Crossrefs

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
Showing 1-10 of 39 results. Next