The OEIS is supported by the many generous donors to the OEIS Foundation. Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A004488 Tersum n + n. 48
 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 (list; graph; refs; listen; history; text; internal format)
 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 LINKS Alois P. Heinz and Gheorghe Coserea, Table of n, a(n) for n = 0..59048 (first 6561 terms from Alois P. Heinz) 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. Cf. A048647, A055115, A055116, A055120, A059249, A117966, A117967, A117968, A225901, A242399, A244042, A263273, A289813, A289814, A289815, A289816, A289831, A289838, A300222, A321464. Sequence in context: A342369 A342842 A048850 * A224976 A011419 A011133 Adjacent sequences:  A004485 A004486 A004487 * A004489 A004490 A004491 KEYWORD nonn,base,look AUTHOR STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified July 4 12:28 EDT 2022. Contains 355075 sequences. (Running on oeis4.)