A263273 Bijective base-3 reverse: a(0) = 0; for n >= 1, a(n) = A030102(A038502(n)) * A038500(n).
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
Offset: 0
Examples
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.
Links
Crossrefs
Programs
-
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}] (* Jean-François Alcover, Dec 29 2015 *)
-
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
-
Scheme
(define (A263273 n) (if (zero? n) n (* (A030102 (A038502 n)) (A038500 n))))
Comments