login
A308364
a(0) = 0, a(3n) = a(n), a(3n+1) = a(n)*3 + 1, a(3n-1) = a(n)*3 - 1.
2
0, 1, 2, 1, 4, 5, 2, 7, 2, 1, 4, 11, 4, 13, 14, 5, 16, 5, 2, 7, 20, 7, 22, 5, 2, 7, 2, 1, 4, 11, 4, 13, 32, 11, 34, 11, 4, 13, 38, 13, 40, 41, 14, 43, 14, 5, 16, 47, 16, 49, 14, 5, 16, 5, 2, 7, 20, 7, 22, 59, 20, 61, 20, 7, 22, 65, 22, 67, 14, 5, 16, 5, 2, 7, 20, 7, 22, 5, 2, 7, 2, 1
OFFSET
0,3
COMMENTS
Defines a function on all the integers, but only nonnegative terms are in the data. A147991 gives the nonnegative fixed points of the function and the nonnegative part of its image.
Consider a Sierpinski arrowhead curve to be formed of vectors placed head to tail and numbered consecutively from 0 at its axis of symmetry. Vector a(n) equals vector n.
Removing all 0's from the balanced ternary expansion of n yields a(n). - Charlie Neder, Jun 03 2019
FORMULA
a(-n) = - a(n).
A307672(a(n)) = A307672(n).
a(A147991(n)) = A147991(n).
a(9n-1) = a(9n-3). a(9n+1) = a(9n+3).
EXAMPLE
As 6 is congruent to 0 modulo 3, a(6) = a(3*2) = a(2).
As 2 is congruent to -1 modulo 3, a(2) = a(3*1 - 1) = a(1)*3 - 1.
As 1 is congruent to 1 modulo 3, a(1) = a(0*1 + 1) = a(0)*3 + 1 = 0*3 + 1 = 1.
So a(2) = a(1)*3 - 1 = 1*3 - 1 = 2. So a(6) = a(2) = 2.
PROG
(PARI) a(n) = if (n == 0, 0, r = n%3; if (r==0, a(n/3), if (r==1, 3*a((n-1)/3)+1, 3*a((n+1)/3)-1))); \\ Michel Marcus, May 29 2019
(Magma) a:=[1]; for n in [2..80] do if n mod 3 eq 2 then a[n]:= 3*a[(n+1) div 3]-1; end if; if n mod 3 eq 1 then a[n]:=3*a[(n-1) div 3]+1; end if; if n mod 3 eq 0 then a[n]:=a[n div 3]; end if; end for; [0] cat a; // Marius A. Burtea, Nov 14 2019
CROSSREFS
Sequence in context: A212713 A072014 A213526 * A210707 A078606 A348706
KEYWORD
nonn,hear
AUTHOR
Peter Munn, May 22 2019
STATUS
approved