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.

A348162 a(n) is the previous term in binary with 0's and 1's put alternatingly before each digit, starting with 0.

This page as a plain text file.
%I A348162 #25 Nov 20 2021 20:41:54
%S A348162 0,0,2,38,9782,641083190,2753431335706502966,
%T A348162 50791843174310108512166439539235563318,
%U A348162 17283568615631356151658578642396687258566665947274335391075779120894446085942
%N A348162 a(n) is the previous term in binary with 0's and 1's put alternatingly before each digit, starting with 0.
%C A348162 The next term is too large to include.
%C A348162 The actual sequence in binary is 0, 00, 0010, 00100110, ... The 0s at the start of each term are required for the sequence to work.
%e A348162 a(2) = 0010;
%e A348162 a(3) = (0010 + 0101 -> 00100110);
%e A348162 a(4) = (00100110 + 01010101 = 0010011000110110).
%e A348162 Full explanation:
%e A348162 Say we have the term 0010.
%e A348162 We get an equal length binary number of alternating 0s and 1s.
%e A348162 In this case it would be 0101, and we interlace them like so:
%e A348162                 0   1   0   1
%e A348162 0010 + 0101 ->    0   0   1   0  -> 00100110
%o A348162 (Python)
%o A348162 def combine(a,b):
%o A348162   c = ''
%o A348162   for i in range(max(len(a),len(b))*2):
%o A348162    if i%2 == 0:
%o A348162     if len(a) > i/2:
%o A348162      c += (a[int(i/2)])
%o A348162    else:
%o A348162     if len(b) > i/2:
%o A348162      c += (b[int(i/2)])
%o A348162   return c
%o A348162 x = '0'
%o A348162 while True:
%o A348162   x = combine(combine(len(x)*'0',len(x)*'1')[:len(x)],x)
%o A348162 (Python)
%o A348162 from itertools import islice
%o A348162 def A348162(): # generator of terms
%o A348162     s = '0'
%o A348162     while True:
%o A348162         yield int(s,2)
%o A348162         s = ''.join(x+y for x, y in zip('01'*((len(s)+1)//2),s))
%o A348162 A348162_list = list(islice(A348162(),9)) # _Chai Wah Wu_, Nov 19 2021
%o A348162 (PARI) a(n) = my(ret=0,s=1); for(i=2,n, ret += 1<<s + ret<<(s<<=1)); ret; \\ _Kevin Ryde_, Nov 19 2021
%Y A348162 Cf. A014707 (bits of terms), A337580.
%K A348162 nonn,base
%O A348162 0,3
%A A348162 _Edward Green_, Oct 03 2021