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
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..19683
Peter Munn, Sierpiński arrowhead with numbered vectors.
Wikipedia, Sierpiński arrowhead curve
FORMULA
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
KEYWORD
nonn,hear
AUTHOR
Peter Munn, May 22 2019
STATUS
approved