%I #27 Aug 07 2024 14:19:38
%S 0,1,2,4,5,3,8,6,7,12,13,14,16,17,15,11,9,10,24,25,26,19,20,18,23,21,
%T 22,36,37,38,40,41,39,44,42,43,48,49,50,52,53,51,47,45,46,33,34,35,28,
%U 29,27,32,30,31,72,73,74,76,77,75,80,78,79,57,58,59,61,62,60,56,54,55,69,70
%N Tersum n + [n/3] (answer recorded in base 10).
%H Alois P. Heinz, <a href="/A071770/b071770.txt">Table of n, a(n) for n = 0..19682</a>
%H P. Mathonet, M. Rigo, M. Stipulanti and N. Zénaïdi, <a href="https://arxiv.org/abs/2201.06636">On digital sequences associated with Pascal's triangle</a>, arXiv:2201.06636 [math.NT], 2022.
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a>
%F 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. See A004482 for references.
%p a:= n-> (l-> add(irem(l[i]+l[i-1], 3)*3^(i-2),
%p i=2..nops(l)))([convert(n, base, 3)[], 0]):
%p seq(a(n), n=0..73); # _Alois P. Heinz_, Aug 07 2024
%o (PARI) a(n)={if(n==0, 0, fromdigits((digits(n,3) + concat([0],digits(n\3,3)))%3,3))} \\ _Andrew Howroyd_, Aug 06 2024
%o (Python)
%o from sympy.ntheory import digits
%o def a(n):
%o d = digits(n, 3)[1:]
%o return int(str(d[0]) + "".join(str((d[i]+d[i-1])%3) for i in range(1, len(d))), 3)
%o print([a(n) for n in range(75)]) # _Michael S. Branicky_, Aug 07 2024
%Y Cf. A004482.
%Y Inverse permutation to A370932.
%K nonn,look
%O 0,3
%A _Paul D. Hanna_, Jun 04 2002
%E a(27) corrected by _Sean A. Irvine_, Aug 06 2024