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 41-50 of 123 results. Next

A263652 Indices in A181391 (Van Eck's Sequence) where a new term first appears.

Original entry on oeis.org

1, 3, 5, 10, 12, 17, 20, 24, 30, 35, 41, 44, 47, 52, 56, 59, 63, 66, 72, 81, 84, 89, 92, 98, 101, 105, 110, 116, 121, 125, 129, 134, 138, 142, 148, 152, 156, 162, 168, 173, 179, 183, 187, 196, 199, 202, 208, 212, 215, 225, 228, 232, 236, 242, 246, 251
Offset: 1

Views

Author

Bob Selcoe, Oct 23 2015

Keywords

Comments

Alternate name: Terms in A171862 in ascending order.
The sequence includes seed value A181391(1)=1.

Crossrefs

Formula

a(n) = A171865(n+1) - 1. - Jan Ritsema van Eck, Jul 24 2019

A308782 Index of first occurrence of n appearing twice in succession in van Eck's sequence (A181391), or 0 if it never occurs.

Original entry on oeis.org

2, 0, 8, 50, 132, 414, 171, 659, 96, 361, 12311, 7224, 5896, 2954, 5804, 72387, 12756, 1292, 4332, 3715, 2704, 1887, 5780, 9837, 11721, 1094, 70067, 32610, 57658, 26146, 167389, 94957, 36588, 19663, 35588, 9627, 108296, 51653, 38147, 54788, 81871, 15502
Offset: 0

Views

Author

Deron Stewart, Jun 24 2019

Keywords

Comments

With V=A181391, a(n) is the smallest number m such that V(m) = V(m-1) = n.
Since van Eck's sequence is generated by considering the gap between identical terms reappearing, it is of interest to consider terms of value n which repeat with a gap of length n.
When this happens the term is repeated in succession.
Some observations that follow from the definition of V:
V(a(n)-1-n) = n. The value n has to appear exactly n terms apart in V to make the following term equal to n, e.g., for n=3: "..., 3, 8, 0, 3, 3, ...".
V(a(n)+1) = 1. Since the term n appeared twice in a row, the following term of V must be 1.
V(a(n)-2) = V(a(n)-n-2) = V(a(n)-2*n-2). The number preceding the repeated terms appears three times with gaps of n.
V(a(n)+2) = the number of terms since the previous repeated value of some number (though it may not be the first time it is repeated). So V(a(n)-V(a(n)+2)) = V(a(n)-V(a(n)+2)-1).

Examples

			With V=A181391 and n=8:
V(95) = V(96) = 8. Therefore, a(8) = 96.
---
V(a(n)-1-n) = n:
a(8) - 1 - 8 = 87.
V(87) = 8.
---
V(a(n)+1) = 1:
a(8) + 1 = 97.
V(97) = 1.
---
V(a(n)-2) = V(a(n)-n-2) = V(a(n)-2*n-2):
a(8) - 2 = 94.
a(8) - 8 - 2 = 86.
a(8) - 2*8 - 2 = 78.
V(94) = V(86) = V(78) = 3.
---
V(a(8)+2) = 46. a(8) - 46 = 50. The previous repeated terms in V are V(50) = V(49) = 5.
		

Crossrefs

Cf. A181391 (van Eck's sequence).

A333359 Variation of Van Eck's sequence A181391: a(n+1) = the minimum positive offset m from a(n) such that the decimal concatenation of a(n-m), a(n-m+1), ..., a(n-m+k) = a(n), where k >= 0; a(n+1)=0 if no such m exists. Start with a(1)=0.

Original entry on oeis.org

0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, 2, 9, 0, 4, 9, 3, 6, 14, 0, 6, 3, 5, 15, 0, 5, 3, 5, 2, 17, 0, 6, 11, 0, 3, 8, 0, 3, 3, 1, 42, 0, 5, 15, 20, 51, 0, 5, 5, 1, 10, 59, 0, 6, 22, 59, 4, 42, 17, 29, 48, 0, 9, 47, 0, 3, 27, 0, 3, 3, 1, 21, 75, 0, 6
Offset: 1

Views

Author

Scott R. Shannon, Mar 16 2020

Keywords

Comments

The terms up to a(56) are the same as A181391 but vary from a(57) and beyond. After 10000 terms the smallest number not appearing is 332.

Examples

			a(42) = 0 as a(41) = 17, and neither '17' or adjacent sequence terms '1' and '7' appear earlier in the sequence.
a(57) = 51 as a(56) = 20, and the value '20' is the concatenation of a(5) = 2 and a(6) = 0, and a(5) is fifty-one terms back from a(56).
		

Crossrefs

A350151 Variation of Van Eck's sequence A181391: a(1) = 0; a(n+1) is the positive offset from the end of the string concatenating a(1) through a(n-1) to the first appearance of a(n). a(n+1) = 0 if a(n) does not appear in the string.

Original entry on oeis.org

0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, 2, 9, 0, 4, 9, 3, 6, 14, 0, 7, 0, 2, 12, 0, 4, 8, 0, 3, 14, 13, 0, 6, 19, 0, 4, 8, 13, 9, 6, 9, 2, 22, 53, 43, 0, 15, 0, 3, 5, 3, 2, 12, 38, 0, 9, 21, 7, 49, 57, 0, 9, 4, 6, 33, 0, 6, 4, 6, 2
Offset: 1

Views

Author

Ya-Ping Lu, Dec 16 2021

Keywords

Comments

This sequence and A181391 differ starting at n = 32.
It seems that a(n)/(n*log(n)) <= 1/(3*log(3)) and lim sup a(n)/(n*log(n)) = 0.24 approximately.

Examples

			a(2) = 0 as a(1) = 0, which does not appear before a(1).
a(15) = 6 as a(14) = 2, which first appears 6th digits back from the end of the string, '0010202216050', the decimal concatenation of a(1) through a(13).
a(42) = 13 as a(41) = 14, which first appears 13 digits back from the end of the string, '001020221605026540530329049361407021204803', the decimal concatenation of a(1) through a(40).
		

Crossrefs

Programs

  • Mathematica
    a[1]=0;a[n_]:=a[n]=Block[{c=""<>ToString/@Most[s=Array[a,n-1]]},Check[Max[StringLength@c-Last@StringPosition[c,ToString@Last@s]]+1,0]];Array[a,81] (* Giorgos Kalogeropoulos, Dec 17 2021 *)
  • Python
    a1 = '0'; print(a1, end =', '); S = a2 = ''
    for n in range(2, 100):
        p = S.rfind(a1); a = str(len(S) - p) if p != -1 else '0'
        print(a, end = ", "); S += a1; a2 = a1; a1 = a

A357908 Index of the first occurrence of n-th prime in Van Eck's sequence (A181391), or 0 if n-th prime never appears.

Original entry on oeis.org

5, 20, 12, 66, 44, 121, 41, 89, 101, 225, 72, 92, 548, 199, 297, 1486, 490, 1001, 735, 455, 420, 611, 772, 673, 187, 1612, 3690, 581, 417, 2584, 7574, 162, 1483, 1048, 689, 330, 1320, 4007, 3739, 2884, 528, 3376, 3045, 3658, 2869, 411, 935, 303, 1751, 1122, 376, 5506, 599, 13191, 494
Offset: 1

Views

Author

G. L. Honaker, Jr., Nov 08 2022

Keywords

Comments

The first 85669653 terms exist and are less than 10^12, see A181391. - Charles R Greathouse IV, Nov 09 2022

Examples

			a(3) = 12 because position 12 of Van Eck's sequence (A181391) is the first occurrence of 3rd prime number, i.e., 5.
		

Crossrefs

Cf. A181391.

Formula

a(n) > prime(n). - Charles R Greathouse IV, Nov 09 2022

A359007 a(n) = b(n-b(n)) where b is Van Eck's sequence A181391.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 5, 1, 0, 0, 0, 2, 4, 0, 5, 0, 6, 0, 3, 0, 0, 2, 5, 0, 4, 14, 6, 3, 0, 6, 15, 5, 3, 9, 0, 5, 3, 0, 6, 5, 0, 3, 8, 3, 6, 0, 3, 2, 0, 0, 5, 9, 0, 4, 1, 0, 0, 3, 32, 0, 4, 11, 0, 7, 17, 0, 3, 11, 0, 2, 31, 6, 31, 0, 0, 6, 3, 0, 9, 2, 33, 3, 0, 3, 15, 0, 5
Offset: 1

Views

Author

Tamas Sandor Nagy, Dec 10 2022

Keywords

Comments

In Van Eck's sequence, b(n) is the distance between b(n-1) and the previous occurrence of b(n-1) there. Taking a(n) = b(n-b(n)) is therefore the distance between the second and third last occurrence of b(n-1) there.
If b(n-1) has not yet occurred three times then the result is a(n) = 0 either by b(n)=0 when b(n-1) has only occurred once, or b(n-b(n)) = 0 when b(n-1) has only occurred twice.

Examples

			b(14) is 2, so we count back two steps to b(12), which is 5. Therefore a(14) = 5. As b(14-1) = b(13) = 0, the three occurrences of 0's are separated by b(14) and b(12) = a(14), that is, 2 and 5 steps:
.
         n: ...  5   6   7   8   9  10  11  12  13  14  15  16  ...
.
                     |<--------5-------->|<--2-->|
                     |                   |       |
                     |                   |       |
      b(n): ...  2,  0,  2,  2,  1,  6,  0,  5,  0,  2,  6,  5, ...
                                             |       |
                                             v       |
                                     a(14) = 5 <-----
                                              two steps
                                                back
		

Crossrefs

Cf. A181391.

Programs

  • PARI
    A181391_vec(N, a=0, i=Map())={vector(N, n, a=if(n>1, iferr(n-mapget(i, a), E, 0)+mapput(i, a, n)))};
    lista(nn) = my(v = A181391_vec(nn)); vector(#v, k, v[k-v[k]]); \\ Michel Marcus, Dec 11 2022

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

A342585 Inventory sequence: record the number of zeros thus far in the sequence, then the number of ones thus far, then the number of twos thus far and so on, until a zero is recorded; the inventory then starts again, recording the number of zeros.

Original entry on oeis.org

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

Views

Author

Joseph Rozhenko, Mar 16 2021

Keywords

Comments

To get started we ask: how many zero terms are there? Since there are no terms in the sequence yet, we record a '0', and having recorded a '0', we begin again: How many zero terms are there? There is now one 0, so we record a '1' and continue. How many 1's are there? There's currently one '1' in the sequence, so we record a '1' and continue. How many 2's are there? There are no 2's yet, so we record a '0', and having recorded a 0, we begin again with the question "how many zero terms are there?" And so on.
a(46) = 0 because no 8's appear before it; but note a higher number, namely 9, has appeared. - Michael S. Branicky, Mar 16 2021
A similar situation occurs at n=124, where 14 has not yet appeared in the sequence, although 15 has appeared.
Reminiscent of Van Eck's sequence A181391. - N. J. A. Sloane, May 02 2021
From Jan Ritsema van Eck, May 02 2021: (Start)
The first 1000 terms seem to grow more or less in saw-tooth fashion with the largest terms (= the number of 0's), as well as the distance between the 0's, both approximately equal to the inverse triangular numbers A003056 (see attached graph #1).
But the picture changes when we go out to 10000 terms. Around the 1700th term, the 1's become more frequent than the 0's and the largest values are consistently somewhat larger than the inverse triangular numbers. Around the 2500th term the 2's become the most frequent number. Also after some 4000 terms, the largest values become much larger than the inverse triangular numbers. See graph #2. (End)
Comment on the colored plot of the first 1000467 terms, from Hans Havermann, May 02 2021: (Start)
If one is drawing a points-joined graph, it will obscure some of the inherent large-number dynamics. To get around that, this plot joins the points with a green line, superimposing the actual points in blue. This plot was created by Mathematica.
Your browser will likely compress the very large image to window size, so click on it to expand.
The points fall into linear features of the various counts of the various integers. The count for each integer changes as we move towards infinity and hence crosses over (changes place with) other counts unpredictably.
I decided to chart (see the blue text) the twenty largest counts at the rightmost spike which runs from the zero at 997010 to the zero at 1000467. These largest values are for the counts of integers 2 to 21 and appear at a(997013) for the 2-count; a(997014) for the 3-count, ..., and a(997032) for the 21-count.
The counts are 15275, 26832, 40162, 48539, 56364, 54372, 53393, 43588, 37288, 27396, 22425, 16735, 13099, 11460, 9466, 8386, 7191, 6478, 5777, and 5208, respectively. In my text they are sorted largest-to-smallest and written "count @ integer-being-counted": 56364 @ 6, 54372 @ 7, 53393 @ 8, 48539 @ 5, ... 5208 @ 21. (End)
A useful view may be gained by plotting the sequence against itself with an offset. Using the "Plot 2" link in the web page footer, enter "A342585" as sequences 1 and 2. Select "Plot Seq2(n+shift) vs Seq1(n)" and "Draw line segments". Start with "1" as the shift. The sequence appears somewhat like a fan, the first 4 or 5 sectors showing clearly, later sectors overlying each other. Larger shift values effectively compress early sectors into the vertical axis, making later sectors more visible. - Peter Munn, May 08 2021
For a version where a row ends not at the first zero, but rather at the last zero, see A347317. - N. J. A. Sloane, Sep 10 2021
For n around 2.5*10^9, the upper envelope of the sequence seems to be growing roughly like n/50, or maybe like O(n/log(n)). - N. J. A. Sloane, Feb 10 2023

Examples

			As an irregular triangle this begins:
   0;
   1,  1,  0;
   2,  2,  2,  0;
   3,  2,  4,  1,  1,  0;
   4,  4,  4,  1,  4,  0;
   5,  5,  4,  1,  6,  2,  1,  0;
   6,  7,  5,  1,  6,  3,  3,  1,  0;
   7,  9,  5,  3,  6,  4,  4,  2,  0;
   8,  9,  6,  4,  9,  4,  5,  2,  1,  3,  0;
   9, 10,  7,  5, 10,  6,  6,  3,  1,  4,  2,  0;
  10, 11,  8,  6, 11,  6,  9,  3,  2,  5,  3,  2,  0;
  ...
For row lengths see A347299. - _N. J. A. Sloane_, Aug 27 2021
From _David James Sycamore_, Oct 18 2021: (Start)
a(1) is 0 because the count is reset, and as yet there is no zero term immediately following another term. a(2) = 1 since the count is reset, a(1) = 0 and a(0) precedes it. The count now increments to terms equal to 1.
a(3) = 1 since a(2) = 1 and a(1) precedes it. a(4) = 0 because there is no term equal to 2 which is immediately preceded by another term.
a(5) = 2 since the count is reset, a(1) = a(4) = 0 and a(0), a(3) respectively, precede them. (End)
		

Crossrefs

Records: A347305 and A348782.
Other inventory-type sequences: A030717, A174382, A333867, A358066, A357443, A356784.
A012257 (cf. also A011784) reverses the inventory process.
See A347062, A347738, A355916, A355917, A355918, A357317 for variants.

Programs

  • AWK
    # See Links section. - Luc Rousseau, May 02 2021
    
  • MATLAB
    function [val,arr]=invSeq(N) % val = Nth term, arr = whole array up to N
    k=0;
    arr=zeros(1,N); % pre-allocate array
    for i=1:N
        an=sum((k==arr(2:i)));
        arr(i)=an;
        if an == 0
            k = 0;
        else
            k=k+1;
        end
    end
    val=arr(end);
    end % Ben Cha, Nov 11 2022
    
  • Maple
    a:= proc(n) option remember; local t;
          t:= `if`(a(n-1)=0, 0, b(n-1)+1);
          b(n):=t; add(`if`(a(j)=t, 1, 0), j=1..n-1)
        end: b(1), a(1):= 0$2:
    seq(a(n), n=1..120);  # Alois P. Heinz, Mar 16 2021
  • Mathematica
    a[n_] := a[n] = Module[{t}, t = If[a[n-1] == 0, 0, b[n-1]+1];
         b[n] = t; Sum[If[a[j] == t, 1, 0], {j, 1, n-1}]];
    b[1] = 0; a[1] = 0;
    Array[a, 120] (* Jean-François Alcover, May 03 2021, after Alois P. Heinz *)
  • PARI
    A342585_vec(N,c=[],i)=vector(N,j, while(#c<=i||#c<=c[i+1], c=concat(c,0)); c[i+=1]+if(c[1+c[i]]++&&!c[i]||j==1,i=0)) \\ M. F. Hasler, Nov 13 2021
    
  • PARI
    \\ See Links section.
    
  • Python
    def calc(required_value_number):
        values_lst = []
        current_count = 0
        new_value = 0
        for i in range(required_value_number):
            new_value = values_lst.count(current_count)
            values_lst.append(new_value)
            if new_value == 0:
                current_count = 0
            else:
                current_count += 1
        return new_value # Written by Gilad Moyal
    
  • Python
    from collections import Counter
    def aupton(terms):
      num, alst, inventory = 0, [0], Counter([0])
      for n in range(2, terms+1):
        c = inventory[num]
        num = 0 if c == 0 else num + 1; alst.append(c); inventory.update([c])
      return alst
    print(aupton(84)) # Michael S. Branicky, Jun 12 2021
    
  • R
    # Prints the first 10,068 terms
    library("dplyr")
    options(max.print=11000)
    inventory <- data.frame(1, 0)
    colnames(inventory) <- c("n", "an")
    value_to_count = 0
    n = 1
    for(x in 1:128) # Increase the 128 for more terms. The number of terms
                    # given is on the order of x^1.9 in the region around 128.
      {
      status <- TRUE
      while(status)
        {
        count <- length(which(inventory$an == value_to_count))
        n = n + 1
        inventory <- rbind(inventory, c(n, count))
        status <- isTRUE(count != 0)
        value_to_count = value_to_count + 1
        }
      value_to_count = 0
      }
    inventory # Damon Lay, Nov 10 2023

A340488 a(n+1) = XOR(a(n),y) for n>=1, where y is the number of m < n such that a(m) = a(n); a(1)=0.

Original entry on oeis.org

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

Views

Author

Ian Hutchinson, Jan 09 2021

Keywords

Comments

It appears that the graph of the first n terms is similar to the graph of the first n/4 terms for sufficiently large values (n > 100).
It appears that among the first 4^n terms, each integer value less than 2^n appears at least (3/4)*2^n times. This would imply that every positive integer appears an infinite number of times.
Yet another variant of the Van Eck sequence A181391. - N. J. A. Sloane, Jan 10 2021
It follows from the definition that when m appears for the first time, it is immediately followed by m, and then if m is even by m+1. A340494 gives a conjectured generating function for when a number appears for the first time. - Rémy Sigrist and N. J. A. Sloane, Jan 10 2021
Conjectures from Rémy Sigrist, Jan 10 2021 (Start)
It appears that the positions of the 0's are given by A336190, and the "y" sequence appears to be A336033.
For a fixed k > 0, let b(n) be the position of the k-th occurrence of n in A340488, Then the sequence { b(n) - A340494(n) } has period 2^m for some m,
- for k = 2 we have period ( 1 ) (the second occurrence appear next to the first).
- for k = 3 we have period ( 4, 10, 4, 4 ),
- for k = 4 we have period (10, 32, 30, 6, 10, 14, 12, 6). (End)
Theorem: Every number appears.
Proof. (i) If there were only finitely many different numbers in the sequence then one number k (say) would appear infinitely often. As the number of k's reaches the next power of 2, 2^m say, we get a term >= 2^m. So the sequence is unbounded. Contradiction. So there are infinitely many different terms.
(ii) To show that every number appears, consider a k-bit number n, n < 2^k. Let a(m) be the first term >= 2^k, where a(m) = a(m-1) XOR y, with a(m-1) < 2^k and y >= 2^k. Let a(m-1) = t. Since this is at least the 2^k-th copy of t, the sequence contains t XOR 0, t XOR 1, t XOR 2, ..., t XOR 2^k-1, and so contains every number from 0 to 2^k-1, and in particular contains n. QED
- Rémy Sigrist and N. J. A. Sloane, Jan 11 2021
Conjecture: Let pi_i(n) denote the number of occurrences of i in the first n terms. Then pi_0(n) >= pi_i(n) for all i, and the first time pi_0(n) = m, pi_i(n) < m for i>0. - N. J. A. Sloane, Jan 13 2021

Examples

			We start with a(1) = 0. 0 has not appeared before, so we set a(2) to bitxor(0,0), or 0. There has now been one previous appearance of 0, so we set a(3) to bitxor(0,1), or 1. There has been no previous appearance of 1, so we set a(4) to 1. There has now been one previous appearance of 1, so we set a(5) to bitxor(1,1), or 0.
		

Crossrefs

Cf. A181391 (Van Eck), A340496 (partial sums), A340499 (first differences), A340500 (running maximum).
See A340494, A340495 for when n first appears.
Cf. also A336033, A336190.

Programs

  • Maple
    b:= proc(n) option remember; `if`(n<1, 0, b(n-1)+x^a(n)) end:
    a:= proc(n) option remember; `if`(n=1, 0, (t->
          Bits[Xor](t, coeff(b(n-2), x, t)))(a(n-1)))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Apr 14 2021
  • Mathematica
    b[n_] := b[n] = If[n < 1, 0, b[n-1] + x^a[n]];
    a[n_] := a[n] = If[n == 1, 0, With[{t = a[n-1]},
         BitXor[t, Coefficient[b[n - 2], x, t]]]];
    Array[a, 100] (* Jean-François Alcover, Jun 27 2021, after Alois P. Heinz *)
  • PARI
    See Links section.
  • Python
    a340488 = [0]
    repeat = [0] # Running tally for occurrences of each value
    for n in range(3414):
        if(a340488[-1] >= len(repeat)):
            repeat.append(0)
        newValue = (a340488[-1] ^ repeat[a340488[-1]])
        repeat[a340488[-1]] += 1
        a340488.append(newValue)
    

A350228 Multiplicative Van Eck sequence: for n >= 2, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = (n-m)*a(n); otherwise a(n+1) = 1. Start with a(1)=1 and a(2)=0.

Original entry on oeis.org

1, 0, 1, 2, 1, 2, 4, 1, 3, 1, 2, 10, 1, 3, 15, 1, 3, 9, 1, 3, 9, 27, 1, 4, 68, 1, 3, 21, 1, 3, 9, 90, 1, 4, 40, 1, 3, 21, 210, 1, 4, 28, 1, 3, 21, 147, 1, 4, 28, 196, 1, 4, 16, 1, 3, 33, 1, 3, 9, 252, 1, 4, 40, 1120, 1, 4, 16, 224, 1, 4, 16, 64, 1, 4, 16, 64, 256, 1, 5, 1, 2, 140
Offset: 1

Views

Author

Jasmine Miller, Dec 20 2021

Keywords

Comments

Theorem 1: There are infinitely many 1's.
Proof: Suppose not. At each successive term, the sequence either grows or returns a 1. If no 1's occur after a certain term called x, then the sequence is monotonically increasing after x. It can be shown that the series grows at least as fast as the factorial between ones. Then for some sufficiently large n > x, a(n) must be greater than any term to appear in the sequence thus far. And a 1 would be returned as the next term.
Theorem 2: If a(n)=k, and k != 1, then an upper bound for the number of terms from the previous 1 to the n-th term is the length of the longest factoring of k such that the m-th factor is at least equal to m. Call this f(n). If a(n)=1, then the last 1 is at most f(a(n-1))+1 terms away.
Proof: This is because the term a(n) can be represented as x(1)*x(2)*...*x(m), with x(i) being the last time a(n-m+i-1) was seen in the sequence. Because you must cross at least the last 1 to get to the previous a(n), x(i) >= i. So the longest string of x(i)'s that can exist is one where the i-th factor is greater than or equal to i. The factors are not necessarily prime. The "longest factoring" (f(n)) refers to the longest string of numbers (x(1)*x(2)*...*x(m)) that can be multiplied to arrive at n.
Theorem 3: If a(n) is prime then a(n-2) is appearing in the sequence for the first time.
Proof: Suppose a(n) is prime. Then a(n-1) must be 1 or it must be a nontrivial divisor of a(n), unless a(n) = 1 (or the trivial case that a(n) = 0). There are no nontrivial divisors of prime numbers so a(n-1) must equal 1. It follows then that a(n-2) is appearing for the first time in the sequence because a(n-1) = 1.

Crossrefs

Programs

  • Mathematica
    f[1]=1; f[n_]:=0; f2[n_]:=0;a:=(Block[{q=f2[x]}, If[q!=0, s[#]=(#-1-q)*(x), s[#]=1]])&; s[1]=1; s[2]=0; x=0;data=Reap[Sow[1];Sow[0];Do[Sow[x=a[n]]; f2[x]=f[x]; f[x]=n, {n, 3, 1000000}]][[2,1]]
  • PARI
    findm(list, n) = {forstep (m=n-1, 1, -1, if (list[m] == list[n], return(m))); return(0);}
    lista(nn) = {my(list = List([1, 0])); for (n=3, nn, my(m = findm(list, n-1)); if (m, listput(list, (n-1-m)*list[n-1]), listput(list, 1););); Vec(list);} \\ Michel Marcus, Jan 16 2022
  • Python
    from itertools import islice, count
    def A350228gen():
        yield from (1,0)
        b, bdict = 0, {1:(1,),0:(2,)}
        for n in count(3):
            if len(l := bdict[b]) > 1:
                m = (n-1-l[-2])*b
                if m in bdict:
                    bdict[m] = (bdict[m][-1],n)
                else:
                    bdict[m] = (n,)
                b = m
            else:
                bdict[1] = (bdict[1][-1],n)
                b = 1
            yield b
    A350228_list = list(islice(A350228gen(),20)) # Chai Wah Wu, Dec 21 2021
    
Previous Showing 41-50 of 123 results. Next