



0, 1, 2, 3, 4, 7, 6, 5, 8, 9, 10, 19, 12, 13, 22, 21, 16, 25, 18, 11, 20, 15, 14, 23, 24, 17, 26, 27, 28, 55, 30, 37, 64, 57, 46, 73, 36, 31, 58, 39, 40, 67, 66, 49, 76, 63, 34, 61, 48, 43, 70, 75, 52, 79, 54, 29, 56, 33, 38, 65, 60, 47, 74, 45, 32, 59, 42, 41, 68, 69, 50, 77, 72, 35, 62, 51, 44, 71, 78, 53, 80, 81
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,3


COMMENTS

Here the base3 reverse has been adjusted so that the maximal suffix of trailing zeros (in base3 representation A007089) stays where it is at the right side, and only the section from the most significant digit to the least significant nonzero digit is reversed, thus making this sequence a selfinverse permutation of nonnegative integers.
Because successive powers of 3 and 9 modulo 2, 4 and 8 are always either constant 1, 1, 1, ... or alternating 1, 1, 1, 1, ... it implies similar simple divisibility rules for 2, 4 and 8 in base 3 as e.g. 3, 9 and 11 have in decimal base (see the Wikipedialink). As these rules do not depend on which direction they are applied from, it means that this bijection preserves the fact whether a number is divisible by 2, 4 or 8, or whether it is not. Thus natural numbers are divided to several subsets, each of which is closed with respect to this bijection. See the Crossrefs section for permutations obtained from these sections.
When polynomials over GF(3) are encoded as natural numbers (coefficients presented with the digits of the base3 expansion of n), this bijection works as a multiplicative automorphism of the ring GF(3)[X]. This follows from the fact that as there are no carries involved, the multiplication (and thus also the division) of such polynomials could be as well performed by temporarily reversing all factors (like they were seen through mirror). This implies also that the sequences A207669 and A207670 are closed with respect to this bijection.


LINKS

Antti Karttunen, Table of n, a(n) for n = 0..6561
Wikipedia, Divisibility rule
Index entries for sequences that are permutations of the natural numbers


FORMULA

a(0) = 0; for n >= 1, a(n) = A030102(A038502(n)) * A038500(n).
Other identities. For all n >= 0:
a(3*n) = 3*a(n).
A000035(a(n)) = A000035(n). [This permutation preserves the parity of n.]
A010873(a(n)) = 0 if and only if A010873(n) = 0. [See the comments section.]


EXAMPLE

For n = 15, A007089(15) = 120. Reversing this so that the trailing zero stays at the right yields 210 = A007089(21), thus a(15) = 21 and vice versa, a(21) = 15.


MATHEMATICA

r[n_] := FromDigits[Reverse[IntegerDigits[n, 3]], 3]; b[n_] := n/ 3^IntegerExponent[n, 3]; c[n_] := n/b[n]; a[0]=0; a[n_] := r[b[n]]*c[n]; Table[a[n], {n, 0, 80}] (* JeanFrançois Alcover, Dec 29 2015 *)


PROG

(Scheme) (define (A263273 n) (if (zero? n) n (* (A030102 (A038502 n)) (A038500 n))))
(Python)
from sympy import factorint
from sympy.ntheory.factor_ import digits
from operator import mul
def a030102(n): return 0 if n==0 else int(''.join(map(str, digits(n, 3)[1:][::1])), 3)
def a038502(n):
f=factorint(n)
return 1 if n==1 else reduce(mul, [1 if i==3 else i**f[i] for i in f])
def a038500(n): return n/a038502(n)
def a(n): return 0 if n==0 else a030102(a038502(n))*a038500(n) # Indranil Ghosh, May 22 2017


CROSSREFS

Bisections: A264983, A264984.
Cf. A000035, A007089, A010873, A030102, A038500, A038502, A207669, A207670.
Cf. also A057889, A264965, A264966, A264980.
Permutations induced by various sections: A263272 (a(2n)/2), A264974 (a(4n)/4), A264978 (a(8n)/8), A264985, A264989.
Cf. also A004488, A140263, A140264, A246207, A246208 (other base3 related permutations).
Sequence in context: A321525 A321524 A321464 * A264966 A308728 A201543
Adjacent sequences: A263270 A263271 A263272 * A263274 A263275 A263276


KEYWORD

nonn,base


AUTHOR

Antti Karttunen, Dec 05 2015


STATUS

approved



