%I
%S 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,
%T 26,27,28,55,30,37,64,57,46,73,36,31,58,39,40,67,66,49,76,63,34,61,48,
%U 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
%N Bijective base3 reverse: a(0) = 0; for n >= 1, a(n) = A030102(A038502(n)) * A038500(n).
%C 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.
%C 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.
%C 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.
%H Antti Karttunen, <a href="/A263273/b263273.txt">Table of n, a(n) for n = 0..6561</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Divisibility_rule">Divisibility rule</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(0) = 0; for n >= 1, a(n) = A030102(A038502(n)) * A038500(n).
%F Other identities. For all n >= 0:
%F a(3*n) = 3*a(n).
%F A000035(a(n)) = A000035(n). [This permutation preserves the parity of n.]
%F A010873(a(n)) = 0 if and only if A010873(n) = 0. [See the comments section.]
%e 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.
%t 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 *)
%o (Scheme) (define (A263273 n) (if (zero? n) n (* (A030102 (A038502 n)) (A038500 n))))
%o (Python)
%o from sympy import factorint
%o from sympy.ntheory.factor_ import digits
%o from operator import mul
%o def a030102(n): return 0 if n==0 else int(''.join(map(str, digits(n, 3)[1:][::1])), 3)
%o def a038502(n):
%o f=factorint(n)
%o return 1 if n==1 else reduce(mul, [1 if i==3 else i**f[i] for i in f])
%o def a038500(n): return n/a038502(n)
%o def a(n): return 0 if n==0 else a030102(a038502(n))*a038500(n) # _Indranil Ghosh_, May 22 2017
%Y Bisections: A264983, A264984.
%Y Cf. A000035, A007089, A010873, A030102, A038500, A038502, A207669, A207670.
%Y Cf. also A057889, A264965, A264966, A264980.
%Y Permutations induced by various sections: A263272 (a(2n)/2), A264974 (a(4n)/4), A264978 (a(8n)/8), A264985, A264989.
%Y Cf. also A004488, A140263, A140264, A246207, A246208 (other base3 related permutations).
%K nonn,base
%O 0,3
%A _Antti Karttunen_, Dec 05 2015
