A308364 a(0) = 0, a(3n) = a(n), a(3n+1) = a(n)*3 + 1, a(3n-1) = a(n)*3 - 1.
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
Examples
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.
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
Programs
-
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
-
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
Comments