A331112 Sum of the digits of the n-th prime number in balanced ternary.
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, -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, 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
Offset: 1
Examples
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.
Links
- Wikipedia, Balanced ternary
Crossrefs
Programs
-
C
#include
#include #define N 1000 /* Largest prime considered - 1 */ char x[N]; int main() { int i, n, v, s, r; for (i=4; i -
Maple
b:= proc(n) `if`(n=0, 0, (d-> `if`(d=2, b(q+1)-1, d+b(q)))(irem(n, 3, 'q'))) end: a:= n-> b(ithprime(n)): seq(a(n), n=1..100); # Alois P. Heinz, Jan 09 2020