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

A019300 First n elements of Thue-Morse sequence A010060 read as a binary number.

Original entry on oeis.org

0, 1, 3, 6, 13, 26, 52, 105, 211, 422, 844, 1689, 3378, 6757, 13515, 27030, 54061, 108122, 216244, 432489, 864978, 1729957, 3459915, 6919830, 13839660, 27679321, 55358643, 110717286, 221434573, 442869146, 885738292, 1771476585, 3542953171
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A010060, A048707, A320916 (bit reversal).

Programs

  • Mathematica
    With[{tm=Nest[Flatten[#/.{0->{0,1},1->{1,0}}]&,{0},7]},Table[ FromDigits[ Take[tm,n],2],{n,40}]] (* Harvey P. Dale, Mar 25 2015 *)
  • PARI
    a(n)=sum(k=1,n,(hammingweight(k)%2)<<(n-k)) \\ Charles R Greathouse IV, May 08 2016
    
  • PARI
    first(n)=my(v=vector(n)); v[1]=1; for(k=2,n,v[k]=2*v[k-1]+hammingweight(k)%2); concat(0,v) \\ Charles R Greathouse IV, May 08 2016
  • Scheme
    (define rdc(lambda(x)(if(null? (cdr x))'()(cons (car x) (rdc (cdr x))))))
    ; if a bit is 1, get 2^i, where i is the index of that bit from right-left
    (define F (lambda (c i)(if (eq? c #\1) (expt 2 i) 0)))
    ; gathers the sum of 2^index for all indices corresponding to a 1
    (define fn (lambda (x sum i stop)(if (eq? i stop) sum (fn (list->string (rdc (string->list x))) (+ sum (F (string-ref x (-(string-length x) 1)) i)) (+ i 1)stop))))
    (define f (lambda (x)(fn (substring thue 0 (+ x 1)) 0 0 (string-length (substring thue 0 (+ x 1))) )))
    (define thue "0110100110010110") ;Feel free to add Thue-Morse sequence of whatever length here
    ; Ariel S Koiman, May 07 2013
    

Formula

a(0) = 0, a(n+1) = 2a(n) + A010060(n). - Ralf Stephan, Sep 16 2003

A377029 a(1) = 0; thereafter in the binary expansion of a(n-1), expand bits: 1->01 and 0->10.

Original entry on oeis.org

0, 2, 6, 22, 406, 92566, 6818458006, 26055178074437806486, 540213899028732737068658940860686756246, 163551003506862550406254063077517364557434408527734307437037618419534882498966
Offset: 1

Views

Author

Darío Clavijo, Oct 13 2024

Keywords

Comments

All terms are even and leading zeros omitted in the final encoding.
Conversely the opposite mapping of bits: 0->01 and 1->10 is A133468.
The bit length of a(n) is 2^(n-1)+1.
The count of bits set for a(n) is A094373(n).
a(n) = 2 (mod 4) for n > 1.
Also all the terms align bitwise to the right.
The hamming distance of a(n) and a(n+1) is in A000079.

Examples

			For n = 5 a(5) = 406 because:
This encoding results in the following tree:
n | a(n)
--+---------------
1 | 0
  | |\
2 | 1 0
  | | |
3 | 1 10
  | | | \
4 | 1 01 10--
  | | |\  \  \
  | | | \  \  \
5 | 1 10 01 01 10
Which also aligns bitwise to the right:
n | a(n)
--+-----------
1 |         0
2 |        10
3 |       110
4 |     10110
5 | 110010110
And 110010110 in base 10 is 406.
		

Crossrefs

Programs

  • Mathematica
    NestList[FromDigits[2 - IntegerDigits[#, 2], 4] &, 0, 10] (* Paolo Xausa, Nov 04 2024 *)
  • Python
    from functools import cache
    A374625 = lambda n: int(bin(n)[2:].replace('0', '2'), 4)
    @cache
    def a(n):
      if n == 1: return 0
      return A374625(a(n-1))
    print([a(n) for n in range(1, 12)])

Formula

a(n) = A320916(2^(n-2)+1) for n > 1.
A000120(a(n+1) XOR a(n)) = A000079(n-2).
a(n) = A374625(a(n-1)) for n > 1. - Paolo Xausa, Nov 04 2024
Showing 1-2 of 2 results.