login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A331112 Sum of the digits of the n-th prime number in balanced ternary. 0
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 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,6
LINKS
Wikipedia, Balanced ternary
FORMULA
a(n) = A065363(A000040(n)). - Alois P. Heinz, Jan 09 2020
EXAMPLE
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.
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
PROG
(C)
#include <stdio.h>
#include <math.h>
#define N 1000 /* Largest prime considered - 1 */
char x[N];
int main()
{
int i, n, v, s, r;
for (i=4; i<N; i+=2)
x[i] = 1;
for (n=3; n<sqrt(N*1.0); n +=2)
for (i=n+n; i<N; i+=n)
x[i] = 1;
for (n = 2; n < N; n++) {
if (x[n] == 0) {
v = n;
s = 0;
while (v != 0) {
r = v % 3;
if (r == 2)
r = -1;
s = s + r;
v = (v - r) / 3;
}
printf("%d, ", s);
}
}
printf("\n");
}
CROSSREFS
See A007605 (sum of digits of primes in base 10); A239619 (sum of digits of primes in base 3).
Sequence in context: A049639 A046555 A336467 * A029382 A073780 A124389
KEYWORD
sign,base,easy
AUTHOR
Thomas König, Jan 09 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 31 14:29 EDT 2024. Contains 375567 sequences. (Running on oeis4.)