login
a(3n) = 0, a(3n+1) = 0, a(3n+2) = 1 + a(n+1).
11

%I #64 Nov 16 2023 07:44:42

%S 0,0,1,0,0,2,0,0,1,0,0,1,0,0,3,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,2,0,

%T 0,1,0,0,1,0,0,4,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,

%U 3,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,3,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,2,0,0,1,0,0,1,0,0,5

%N a(3n) = 0, a(3n+1) = 0, a(3n+2) = 1 + a(n+1).

%C For n >= 1, a(n) gives the distance of n in square array A191450 from its leftmost column.

%C The sequence 0,1,0,0,0,2,0,...,i.e., (a(n)) with the first term removed, is the unique fixed point of the constant length 3 morphism N -> 0 N+1 0 on the infinite alphabet {0,1,...,N,...}. - _Michel Dekking_, Sep 09 2022

%C a(n) is the number of trailing 1 digits of n-1 written in ternary, for n>=1. - _Kevin Ryde_, Sep 09 2022

%H Antti Karttunen, <a href="/A253786/b253786.txt">Table of n, a(n) for n = 0..10000</a>

%F Other identities and observations. For all n >= 1:

%F a(n) = A254046(n)-1.

%F a(n) <= A254045(n) <= A253894(n).

%F a(3n-1) = A254046(n). - _Cyril Damamme_, Aug 04 2015

%F a(n) = A007949(2n-1), i.e., the 3-adic valuation of 2n-1. - _Cyril Damamme_, Aug 04 2015

%F From _Antti Karttunen_, Sep 12 2017: (Start)

%F For all n >= 1:

%F a(n) = A007814(A064216(n)) = A007814(A254104(n)) = A135523(A245611(n)).

%F a(A048673(n)) = a(A254103(n)) = A007814(n).

%F a(A244154(n)) = A007814(1+n).

%F a(A245612(n)) = A135523(n). (End)

%F Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/2. - _Amiram Eldar_, Nov 16 2023

%t With[{nmax=200},IntegerExponent[2Range[0,nmax]-1,3]] (* _Paolo Xausa_, Nov 09 2023 *)

%o (Scheme, with memoization-macro definec)

%o (definec (A253786 n) (if (= 2 (modulo n 3)) (+ 1 (A253786 (/ (+ 1 n) 3))) 0))

%o (PARI) a(n) = n--; my(ret=0,r); while([n,r]=divrem(n,3); r==1, ret++); ret; \\ _Kevin Ryde_, Sep 13 2022

%Y One less than A254046.

%Y Cf. A007814, A007949, A048673, A064216, A135523, A191450 (A254051), A253887, A253894, A254045, A254103, A254104, A245611.

%K nonn,easy

%O 0,6

%A _Antti Karttunen_, Jan 22 2015