login
Fixed point of the morphism 1 -> 1121211, 2 -> 1121212121211, starting from a(1) = 1.
2

%I #18 Feb 16 2025 15:37:04

%S 1,1,2,1,2,1,1,1,1,2,1,2,1,1,1,1,2,1,2,1,2,1,2,1,2,1,1,1,1,2,1,2,1,1,

%T 1,1,2,1,2,1,2,1,2,1,2,1,1,1,1,2,1,2,1,1,1,1,2,1,2,1,1,1,1,2,1,2,1,1,

%U 1,1,2,1,2,1,1,1,1,2,1,2,1,2,1,2,1,2,1,1,1,1,2,1,2,1,1,1,1,2,1,2,1,2,1,2,1

%N Fixed point of the morphism 1 -> 1121211, 2 -> 1121212121211, starting from a(1) = 1.

%C Length of n-th run of identical symbols in A051069.

%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>

%F Sum_{k=1..n} a(k) = A007417(n).

%t Nest[ Function[ l, {Flatten[(l /. {1 -> {1, 1, 2, 1, 2, 1, 1}, 2 -> {1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1}})]}], {1}, 3] (* _Robert G. Wilson v_, Feb 26 2005 *)

%o (Python)

%o from sympy import integer_log

%o def A007417(n):

%o def f(x): return n+x-sum(((m:=x//9**i)-2)//3+(m-1)//3+2 for i in range(integer_log(x,9)[0]+1))

%o m, k = n, f(n)

%o while m != k: m, k = k, f(k)

%o return m

%o def A092400(n): return A007417(n)-A007417(n-1) if n>1 else 1 # _Chai Wah Wu_, Feb 16 2025

%Y Cf. A007417, A051069.

%K easy,nonn

%O 1,3

%A _Philippe Deléham_, Mar 21 2004

%E More terms from _Robert G. Wilson v_, Feb 26 2005