login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A014710
The regular paper-folding (or dragon curve) sequence.
11
2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2
OFFSET
0,1
LINKS
G. Melançon, Factorizing infinite words using Maple, MapleTech journal, vol. 4, no. 1, 1997, pp. 34-42, esp. p. 36.
FORMULA
Set a=2, b=1, S(0)=a, S(n+1) = S(n)aF(S(n)), where F(x) reverses x and then interchanges a and b; sequence is limit S(infinity).
a(4*n) = 2, a(4*n+2) = 1, a(2*n+1) = a(n).
MATHEMATICA
Nest[Append[#1, If[EvenQ[#2], 2 - BitAnd[1, #2/2], #1[[Ceiling[#2/2]]]]] & @@ {#, Length@ #} &, {2}, 105] (* Michael De Vlieger, Apr 08 2021 *)
PROG
(PARI) a(n)=if(n%2==0, 2-bitand(1, n\2), a(n\2) );
for(n=0, 122, print1(a(n), ", "))
(Python)
def A014710(n):
s = bin(n+1)[2:]
m = len(s)
i = s[::-1].find('1')
return 2-int(s[m-i-2]) if m-i-2 >= 0 else 2 # Chai Wah Wu, Apr 08 2021
CROSSREFS
See A014577 for more references and more terms.
The following are all essentially the same sequence: A014577, A014707, A014709, A014710, A034947, A038189, A082410. - N. J. A. Sloane, Jul 27 2012
Sequence in context: A323018 A192064 A225182 * A055174 A096369 A332289
KEYWORD
nonn
AUTHOR
STATUS
approved