This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A004488 #79 Oct 29 2023 21:03:12 %S A004488 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, %T A004488 13,54,56,55,60,62,61,57,59,58,72,74,73,78,80,79,75,77,76,63,65,64,69, %U A004488 71,70,66,68,67,27,29,28,33,35,34,30,32,31,45,47,46,51 %N A004488 Tersum n + n. %C A004488 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 %C A004488 a(a(n)) = n, a self-inverse permutation of the nonnegative integers. - _Reinhard Zumkeller_, Dec 19 2003 %C A004488 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 %H A004488 Gheorghe Coserea, <a href="/A004488/b004488.txt">Table of n, a(n) for n = 0..59048</a> (first 6561 terms from Alois P. Heinz) %H A004488 <a href="/index/Ca#CARRYLESS">Index entries for sequences related to carryless arithmetic</a> %H A004488 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A004488 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. %F A004488 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 %F A004488 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 %p A004488 a:= proc(n) local t, r, i; %p A004488 t, r:= n, 0; %p A004488 for i from 0 while t>0 do %p A004488 r:= r+3^i *irem(2*irem(t, 3, 't'), 3) %p A004488 od; r %p A004488 end: %p A004488 seq(a(n), n=0..80); # _Alois P. Heinz_, Sep 07 2011 %t A004488 a[n_] := FromDigits[Mod[3-IntegerDigits[n, 3], 3], 3]; Table[a[n], {n, 0, 66}] (* _Jean-François Alcover_, Mar 03 2014 *) %o A004488 (Haskell) %o A004488 a004488 0 = 0 %o A004488 a004488 n = if d == 0 then 3 * a004488 n' else 3 * a004488 n' + 3 - d %o A004488 where (n', d) = divMod n 3 %o A004488 -- _Reinhard Zumkeller_, Mar 12 2014 %o A004488 (PARI) a(n) = my(b=3); fromdigits(apply(d->(b-d)%b, digits(n, b)), b); %o A004488 vector(67, i, a(i-1)) \\ _Gheorghe Coserea_, Apr 23 2018 %o A004488 (Python) %o A004488 from sympy.ntheory.factor_ import digits %o A004488 def a(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3) # _Indranil Ghosh_, Jun 06 2017 %Y A004488 Column k=0 of A253586, A253587. %Y A004488 Column k=3 of A248813. %Y A004488 Row / column 2 of A325820. %Y A004488 Main diagonal of A004489. %Y A004488 Cf. A048647, A055115, A055116, A055120, A059249, A117966, A117967, A117968, A225901, A242399, A244042, A263273, A289813, A289814, A289815, A289816, A289831, A289838, A300222, A321464. %K A004488 nonn,base,look %O A004488 0,2 %A A004488 _N. J. A. Sloane_