A008351 a(n) is the concatenation of a(n-1) and a(n-2) with a(1)=1, a(2)=2.
1, 2, 21, 212, 21221, 21221212, 2122121221221, 212212122122121221212, 2122121221221212212122122121221221, 2122121221221212212122122121221221212212122122121221212
Offset: 1
References
- D. E. Knuth, "The Art of Programming", Volume 1, "Fundamental Algorithms", third edition, problem 36 on page 86.
Links
- K. B. Stolarsky, Beatty sequences, continued fractions, and certain shift operators, Canadian Math. Bull. 19 (1976) pp. 473-482.
- Wikipedia, Lindenmayer system
Programs
-
Mathematica
a[1] = 1; a[2] = 2; a[n_] := 10^Floor[ Log[10, a[n - 2]] +1]*a[n - 1] + a[n - 2] (* Robert G. Wilson v, Jan 26 2006 *)
-
PARI
a(n) = if (n<=2, n, eval(concat(Str(a(n-1)), Str(a(n-2))))); \\ Michel Marcus, May 14 2017
-
PARI
a(n) = {if(n<=2, return(n)); my(v=vector(fibonacci(n),i,2), phi2 = (3+sqrt(5))/2, b = vector(fibonacci(n-2), i, (i*(sqrt(5)+3)/2))\1); for(i=1, fibonacci(n-2), v[(i*(3+sqrt(5))/2)\1] = 1); sum(i=1,#v,10^(#v-i) * v[i])} a(n) = my(v=vector(n)); if(n <= 2, return(n)); v[1] = 1; v[2] = 2; for(i=3, n, v[i]=eval(concat(Str(v[i-1]), Str(v[i-2])))); v[#v] \\ David A. Corneth, May 14 2017
Extensions
Title clarified by Chai Wah Wu, Mar 17 2021
Comments