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 A331112 #15 Jan 13 2020 17:45:52 %S A331112 0,1,-1,1,1,3,-1,1,-1,1,3,3,-3,-1,-1,-1,-1,1,3,-1,1,1,1,1,1,1,3,1,3,1, %T A331112 -1,-3,-1,1,-3,-1,1,1,-1,1,-1,1,1,3,1,3,1,1,1,3,-1,-1,1,1,-1,1,1,3,3, %U A331112 3,5,-1,3,-1,1,1,3,5,1,3,3,3,-3,-1,-1,-3,-1,-1,-3,1,-3,-1,-1,1,1,1,-3,-1,-1,1,-1,-1,1,-1,3,-1,-1,1,3,1 %N A331112 Sum of the digits of the n-th prime number in balanced ternary. %H A331112 Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a> %F A331112 a(n) = A065363(A000040(n)). - _Alois P. Heinz_, Jan 09 2020 %e A331112 Using T for -1 and _bt as suffix for balanced ternary: 2_10 = 1T_bt, sum of digits is zero; 3_10 = 10_bt, sum of digits is 1 and 5_10 = 1TT, sum of digits = -1. %p A331112 b:= proc(n) `if`(n=0, 0, (d-> `if`(d=2, %p A331112 b(q+1)-1, d+b(q)))(irem(n, 3, 'q'))) %p A331112 end: %p A331112 a:= n-> b(ithprime(n)): %p A331112 seq(a(n), n=1..100); # _Alois P. Heinz_, Jan 09 2020 %o A331112 (C) %o A331112 #include <stdio.h> %o A331112 #include <math.h> %o A331112 #define N 1000 /* Largest prime considered - 1 */ %o A331112 char x[N]; %o A331112 int main() %o A331112 { %o A331112 int i, n, v, s, r; %o A331112 for (i=4; i<N; i+=2) %o A331112 x[i] = 1; %o A331112 for (n=3; n<sqrt(N*1.0); n +=2) %o A331112 for (i=n+n; i<N; i+=n) %o A331112 x[i] = 1; %o A331112 for (n = 2; n < N; n++) { %o A331112 if (x[n] == 0) { %o A331112 v = n; %o A331112 s = 0; %o A331112 while (v != 0) { %o A331112 r = v % 3; %o A331112 if (r == 2) %o A331112 r = -1; %o A331112 s = s + r; %o A331112 v = (v - r) / 3; %o A331112 } %o A331112 printf("%d,",s); %o A331112 } %o A331112 } %o A331112 printf("\n"); %o A331112 } %Y A331112 See A007605 (sum of digits of primes in base 10); A239619 (sum of digits of primes in base 3). %Y A331112 Cf. A000040, A065363, A117966. %K A331112 sign,base,easy %O A331112 1,6 %A A331112 _Thomas König_, Jan 09 2020