[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Search: a253586 -id:a253586
     Sort: relevance | references | number | modified | created      Format: long | short | data
Tersum n + n.
+10
57
0, 2, 1, 6, 8, 7, 3, 5, 4, 18, 20, 19, 24, 26, 25, 21, 23, 22, 9, 11, 10, 15, 17, 16, 12, 14, 13, 54, 56, 55, 60, 62, 61, 57, 59, 58, 72, 74, 73, 78, 80, 79, 75, 77, 76, 63, 65, 64, 69, 71, 70, 66, 68, 67, 27, 29, 28, 33, 35, 34, 30, 32, 31, 45, 47, 46, 51
OFFSET
0,2
COMMENTS
Could also be described as "Write n in base 3, then replace each digit with its base-3 negative" as with A048647 for base 4. - Henry Bottomley, Apr 19 2000
a(a(n)) = n, a self-inverse permutation of the nonnegative integers. - Reinhard Zumkeller, Dec 19 2003
First 3^n terms of the sequence form a permutation s(n) of 0..3^n-1, n>=1; the number of inversions of s(n) is A016142(n-1). - Gheorghe Coserea, Apr 23 2018
FORMULA
Tersum m + n: write m and n in base 3 and add mod 3 with no carries, e.g., 5 + 8 = "21" + "22" = "10" = 1.
a(n) = Sum(3-d(i)-3*0^d(i): n=Sum(d(i)*3^d(i): 0<=d(i)<3)). - Reinhard Zumkeller, Dec 19 2003
a(3*n) = 3*a(n), a(3*n+1) = 3*a(n)+2, a(3*n+2) = 3*a(n)+1. - Robert Israel, May 09 2014
MAPLE
a:= proc(n) local t, r, i;
t, r:= n, 0;
for i from 0 while t>0 do
r:= r+3^i *irem(2*irem(t, 3, 't'), 3)
od; r
end:
seq(a(n), n=0..80); # Alois P. Heinz, Sep 07 2011
MATHEMATICA
a[n_] := FromDigits[Mod[3-IntegerDigits[n, 3], 3], 3]; Table[a[n], {n, 0, 66}] (* Jean-François Alcover, Mar 03 2014 *)
PROG
(Haskell)
a004488 0 = 0
a004488 n = if d == 0 then 3 * a004488 n' else 3 * a004488 n' + 3 - d
where (n', d) = divMod n 3
-- Reinhard Zumkeller, Mar 12 2014
(PARI) a(n) = my(b=3); fromdigits(apply(d->(b-d)%b, digits(n, b)), b);
vector(67, i, a(i-1)) \\ Gheorghe Coserea, Apr 23 2018
(Python)
from sympy.ntheory.factor_ import digits
def a(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3) # Indranil Ghosh, Jun 06 2017
CROSSREFS
Column k=0 of A253586, A253587.
Column k=3 of A248813.
Row / column 2 of A325820.
Main diagonal of A004489.
KEYWORD
nonn,base,look
STATUS
approved
A ternary code: inverse of A060583.
+10
7
0, 2, 1, 8, 7, 6, 4, 3, 5, 24, 26, 25, 23, 22, 21, 19, 18, 20, 12, 14, 13, 11, 10, 9, 16, 15, 17, 72, 74, 73, 80, 79, 78, 76, 75, 77, 69, 71, 70, 68, 67, 66, 64, 63, 65, 57, 59, 58, 56, 55, 54, 61, 60, 62, 36, 38, 37, 44, 43, 42, 40, 39, 41, 33, 35, 34, 32, 31, 30, 28, 27, 29
OFFSET
0,2
COMMENTS
Write n in base 3, then (working from left to right) if the k-th digit of n is equal to the digit to the left of it then this is the k-th digit of a(n), otherwise the k-th digit of a(n) is the element of {0,1,2} which has not just been compared, then read result as a base 3 number.
FORMULA
a(n) = 3a([n/3])+(-[n/3]-n mod 3) = 3a([n/3]) + A060588(n).
a(n) = A253586(n,floor(n/3)) = A253587(n,floor(n/3)). - Alois P. Heinz, Jan 09 2015
EXAMPLE
a(76) = 46 since 76 written in base 3 is 2211; this gives a first digit of 1( = 3-2-0), a second digit of 2( = 2 = 2), a third digit of 0( = 3-1-2) and a fourth digit of 1( = 1 = 1); 1201 base 3 is 46.
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Henry Bottomley, Apr 04 2001
STATUS
approved
The sum of the i-th ternary digits of n, k, and T(n,k) equals 0 (mod 3) for each i>=0 (leading zeros included); triangle T(n,k), n>=0, 0<=k<=n, read by rows.
+10
4
0, 2, 1, 1, 0, 2, 6, 8, 7, 3, 8, 7, 6, 5, 4, 7, 6, 8, 4, 3, 5, 3, 5, 4, 0, 2, 1, 6, 5, 4, 3, 2, 1, 0, 8, 7, 4, 3, 5, 1, 0, 2, 7, 6, 8, 18, 20, 19, 24, 26, 25, 21, 23, 22, 9, 20, 19, 18, 26, 25, 24, 23, 22, 21, 11, 10, 19, 18, 20, 25, 24, 26, 22, 21, 23, 10, 9, 11
OFFSET
0,2
LINKS
Wikipedia, Set (game)
FORMULA
T(n,k) = T(floor(n/3),floor(k/3))*3+(6-(n mod 3)-(k mod 3) mod 3), T(0,0) = 0.
EXAMPLE
Triangle T(n,k) begins:
0;
2, 1;
1, 0, 2;
6, 8, 7, 3;
8, 7, 6, 5, 4;
7, 6, 8, 4, 3, 5;
3, 5, 4, 0, 2, 1, 6;
5, 4, 3, 2, 1, 0, 8, 7;
4, 3, 5, 1, 0, 2, 7, 6, 8;
MAPLE
T:= proc(n, k) local i, j; `if`(n=0 and k=0, 0,
T(iquo(n, 3, 'i'), iquo(k, 3, 'j'))*3 +irem(6-i-j, 3))
end:
seq(seq(T(n, k), k=0..n), n=0..14);
CROSSREFS
Column k=0 gives A004488.
Main diagonal gives A001477.
T(n,floor(n/3)) gives A060587.
KEYWORD
nonn,base,tabl,look
AUTHOR
Alois P. Heinz, Jan 04 2015
STATUS
approved

Search completed in 0.006 seconds