%I #10 Apr 15 2022 10:32:58
%S 0,2,18,2,2,18,18,6,18,2,18,5,2,18,6,18,6,18,18,18,5,6,18,5,18,6,18,2,
%T 5,6,18,18,18,5,18,5,2,6,18,18,5,13,6,13,6,18,8,18,6,5,6,18,6,18,18,
%U 18,8,18,5,18,5,18,5,6,6,18,18,18,8,5,13,5,18,18,13,6,13,18,18,8,18,2,18,18,5,6,13,6,13,6
%N The maximum sum of base-3 digits occurring among all numbers reached after n, when iterating map x -> A353313(x) starting from x=n, or -1 if no finite cycle is ever reached.
%H Antti Karttunen, <a href="/A353309/b353309.txt">Table of n, a(n) for n = 0..19683</a>
%e When starting iterating A353313 from n=7, we obtain -> 14 -> 25 -> 44 -> 75 -> 25 -> 44 -> 75 -> 25 -> etc, ad infinitum. Applying A053735 to all distinct terms encountered after 7, that is [14, 25, 44, 75] gives us base-3 digit sums [4, 5, 6, 5], therefore a(7) = 6, which is the largest sum.
%o (PARI)
%o A053735(n) = sumdigits(n, 3);
%o A353313(n) = { my(r=(n%3)); if(!r,n/3,((5*((n-r)/3)) + r + 3)); };
%o A353309(n) = { my(visited = Map(), m=0); for(j=1, oo, n = A353313(n); m=max(m,A053735(n)); if(mapisdefined(visited, n), return(m), mapput(visited, n, j))); };
%Y Cf. A053735, A353313.
%Y Cf. also A352895.
%K nonn,look
%O 0,2
%A _Antti Karttunen_, Apr 13 2022