A171960 Values of the 2-complement of n in ternary representation.
2, 1, 0, 5, 4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
Offset: 0
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
a[n_] := 3^(1 + Floor[Log[3, n]]) - n - 1; a[0] = 2; Array[a, 100] (* Amiram Eldar, Apr 03 2025 *)
-
PARI
a(n) = 3^(if(n,logint(n,3))+1) - 1 - n; \\ Kevin Ryde, Jul 16 2020