%I
%S 1,1,1,1,1,1,3,1,1,1,1,3,1,3,1,5,3,3,5,3,5,3,3,1,3,1,1,1,1,3,1,3,3,5,
%T 3,5,3,5,5,5,7,5,7,7,5,9,7,7,11,7,9,7,7,7,11,9,13,5,9,5,15,7,9,7,7,7,
%U 7,7,5,5,5,3,5,3,5,3,3,1,3,1,1,1,1,3,1,3
%N a(n) is the numbers of ways to write 2*n = u + v where the ternary representations of u and of v have the same number of digits d for d = 0..2.
%C In other words, a(n) is the number of ways to write 2*n as the sum of two ternary anagrams.
%C Leading zeros are ignored.
%C Two ternary anagrams have necessarily the same parity, hence an odd number cannot be the sum of two ternary anagrams.
%H Rémy Sigrist, <a href="/A330827/b330827.txt">Table of n, a(n) for n = 0..19683</a>
%H Rémy Sigrist, <a href="/A330827/a330827.gp.txt">PARI program for A330827</a>
%H Rémy Sigrist, <a href="/A330827/a330827.png">Scatterplot of (x, y) such that 0 <= x, y <= 3^7 and x and y are ternary anagrams</a> (a(n) corresponds to the number of pixels (x, y) such that x+y = n)
%e For n = 6:
%e  we can write 12 as u + v in the following ways:
%e u v ter(u) ter(v)
%e    
%e 5 7 12 21
%e 6 6 20 20
%e 7 5 21 12
%e  hence a(6) = 3.
%o (PARI) See Links section.
%Y Cf. A331216 (binary analog), A331218 (decimal analog).
%K nonn,base
%O 0,7
%A _Rémy Sigrist_, Jan 12 2020
