login
Reverse runs of nonzero digits in ternary expansion of n and convert back to decimal.
1

%I #11 Nov 19 2018 12:23:03

%S 0,1,2,3,4,5,6,7,8,9,10,19,12,13,14,15,16,17,18,11,20,21,22,23,24,25,

%T 26,27,28,55,30,37,46,57,64,73,36,31,58,39,40,41,42,43,44,45,32,59,48,

%U 49,50,51,52,53,54,29,56,33,38,47,60,65,74,63,34,61,66,67

%N Reverse runs of nonzero digits in ternary expansion of n and convert back to decimal.

%C This sequence is a self-inverse permutation of nonnegative integers.

%H Rémy Sigrist, <a href="/A321767/b321767.txt">Table of n, a(n) for n = 0..19683</a>

%H Rémy Sigrist, <a href="/A321767/a321767.gp.txt">PARI program for A321767</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(3 * n) = 3 * a(n).

%e For n = 11111:

%e - the ternary representation of 11111 is "120020112",

%e - we have three runs of nonzero digits: "12", "2" and "112",

%e - we replace the first by the third, the third by the first and the second remains in place,

%e - the result is: "112002012",

%e - and a(11111) = 10265.

%o (PARI) See Links section.

%Y See A321726 for a similar sequence.

%K nonn,base,look

%O 0,3

%A _Rémy Sigrist_, Nov 18 2018