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.
%I A349249 #6 Dec 04 2021 12:41:51 %S A349249 6,5,3,4,6,8,10,12,14,16,4,3,1,2,4,6,8,10,12,14,2,0,0,2,4,6,8,10,12, %T A349249 14,0,2,2,6,4,6,8,10,12,14,4,4,4,4,6,6,8,10,12,14,6,6,6,6,6,10,8,10, %U A349249 12,14,8,8,8,8,8,8,8,10,12,14,10,10,10,10,10,10,10 %N A349249 Number of iterations of the digit-census function A348783 until an element of a cycle is reached. %C A349249 The length of the cycle in which the trajectory of n will end, is equal to the size of the full orbit of n under A348783, A349250(n), minus a(n). %F A349249 a(n) = 0 iff n is element of a cycle (or "loop") under iterations of A348783, %F A349249 otherwise a(n) = 1 + a(A348783(n)). %e A349249 Under iterations of A348783, 0 -> 1 -> 10 -> 11 -> 20 -> 101 -> 21 -> 110 -> 21 -> ..., so the cycle (21, 110) is reached after a(0) = 6 iterations, and also a(1) = 5, a(10) = 4, a(11) = 3, a(20) = 2, a(101) = 1 and a(21) = a(110) = 0 because these two are elements of this cycle. %e A349249 Similarly, 2 -> 100 -> 12 -> 110 -> 21 -> ..., so the same cycle is reached in a(2) = 3 iterations, and also a(100) = 2, a(12) = 1. %e A349249 Then, 3 -> 1000 -> 13 -> 1010 -> 22 -> 200 -> 102 -> 111 -> 30 -> 1001 -> 22 -> 200 -> ..., here the cycle (22, 200, 102, 111, 30, 1001) is reached after a(3) = 4 iterations, and a(1000) = 3, a(13) = 2, a(1010) = 1 and a(n) = 0 for the elements of that cycle. %o A349249 (PARI) apply( {A349249(n, S=[n], T)=while(!setsearch(S, n=A348783(n)), S=setunion(S, [n])); if(T,T-#S,A349249(n,,#S))}, [0..99]) %o A349249 (Python) %o A349249 def f(n): %o A349249 s = str(n) %o A349249 return int("".join(str(s.count(d)) for d in "9876543210").lstrip("0")) %o A349249 def a(n): %o A349249 orbit, fn = [n], f(n) %o A349249 while fn not in orbit: %o A349249 orbit.append(fn) %o A349249 n, fn = fn, f(fn) %o A349249 return orbit.index(fn) %o A349249 print([a(n) for n in range(77)]) # _Michael S. Branicky_, Nov 18 2021 %Y A349249 Cf. A348783, A349250 (length of the full orbit). %K A349249 nonn %O A349249 0,1 %A A349249 _M. F. Hasler_, Nov 17 2021