login
Write n in base 3, change twos in ones and ones in twos, reverse.
1

%I #8 Jun 20 2016 10:16:26

%S 0,2,1,2,8,5,1,7,4,2,20,11,8,26,17,5,23,14,1,19,10,7,25,16,4,22,13,2,

%T 56,29,20,74,47,11,65,38,8,62,35,26,80,53,17,71,44,5,59,32,23,77,50,

%U 14,68,41,1,55,28,19,73,46,10

%N Write n in base 3, change twos in ones and ones in twos, reverse.

%C This is not to A036044 as A007089 is to A007088: despite similarity here the operation performed is not a base 3 complement. Fixed points begin: 5, 7, 11, 19, 29, 44, 50, 55.

%H Alois P. Heinz, <a href="/A137305/b137305.txt">Table of n, a(n) for n = 0..6561</a>

%F a(3^n) = 2. a(2*3^n) = 1.

%e 53 -> 1222 -> 2111 -> 1112 -> 41.

%p a:= proc(n) local m, r; m, r:= n, 0; while m>0

%p do r:=r*3+[0, 2, 1][1+irem(m, 3, 'm')] od; r

%p end:

%p seq(a(n), n=0..100); # _Alois P. Heinz_, Jun 20 2016

%t a[n_] := FromDigits[ Reverse[ IntegerDigits[n, 3] /. {1 -> 2, 2 -> 1}], 3] (* _Giovanni Resta_, Jun 20 2016 *)

%Y Cf. A007089, A036044.

%K base,easy,nonn

%O 0,2

%A _Jonathan Vos Post_, Apr 20 2008

%E Edited and corrected by _Giovanni Resta_, Jun 20 2016