%I #22 Feb 28 2020 00:27:28
%S 0,1,2,1,4,5,2,7,8,1,10,11,4,13,14,5,16,17,2,19,20,7,22,23,8,25,26,1,
%T 28,29,10,11,4,11,14,5,4,17,2,13,40,41,14,43,44,5,46,47,16,49,50,17,
%U 52,53,2,55,56,19,58,59,20,7,22,7,8,25,22,1,28,23,70,71
%N Starting from n: as long as the decimal representation starts with a positive multiple of 3, divide the largest such prefix by 3; a(n) corresponds to the final value.
%C As long as we have a number whose decimal representation is the concatenation of a positive multiple of 3, say u, and a minimal string possibly empty, say v, we replace this number with the concatenation of u/3 and v; eventually none of the prefixes will be a positive multiple of 3.
%H Rémy Sigrist, <a href="/A329424/b329424.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) <= n.
%e For n = 1011:
%e - 1011 gives 1011/3 = 337,
%e - 337 gives 33/3 followed by 7 = 117,
%e - 117 gives 117/3 = 39,
%e - 39 gives 39/3 = 13,
%e - neither 1 nor 13 is a multiple of 3, so a(1011) = 13.
%o (PARI) t(n) = if (n==0, 0, n%3==0, n/3, 10*t(n\10)+(n%10))
%o a(n) = while (n!=n=t(n),); n
%Y See A327539 for similar sequences.
%K nonn,base
%O 0,3
%A _Rémy Sigrist_, Nov 30 2019