A137305 Write n in base 3, change twos in ones and ones in twos, reverse.
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, 56, 29, 20, 74, 47, 11, 65, 38, 8, 62, 35, 26, 80, 53, 17, 71, 44, 5, 59, 32, 23, 77, 50, 14, 68, 41, 1, 55, 28, 19, 73, 46, 10
Offset: 0
Examples
53 -> 1222 -> 2111 -> 1112 -> 41.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..6561
Programs
-
Maple
a:= proc(n) local m, r; m, r:= n, 0; while m>0 do r:=r*3+[0, 2, 1][1+irem(m, 3, 'm')] od; r end: seq(a(n), n=0..100); # Alois P. Heinz, Jun 20 2016
-
Mathematica
a[n_] := FromDigits[ Reverse[ IntegerDigits[n, 3] /. {1 -> 2, 2 -> 1}], 3] (* Giovanni Resta, Jun 20 2016 *)
Formula
a(3^n) = 2. a(2*3^n) = 1.
Extensions
Edited and corrected by Giovanni Resta, Jun 20 2016
Comments