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.
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
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.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..25000
- Ian Hutchinson, Graph of first 3500 terms
- Rémy Sigrist, PARI program for A340488
Crossrefs
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)
Comments