login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Consider the least base b >= 2 where the sum of digits of n is a prime number; a(n) corresponds to this prime number.
2

%I #10 Jun 18 2022 07:43:24

%S 2,2,2,2,2,3,2,2,2,3,2,3,3,3,2,2,2,3,2,3,3,5,2,3,3,3,3,3,2,5,2,2,2,3,

%T 2,3,3,3,2,3,3,5,3,3,7,5,2,3,3,5,3,7,2,5,3,3,7,5,5,5,5,3,13,2,2,3,2,3,

%U 3,7,2,3,3,5,3,7,3,5,2,3,3,3,3,3,5,5,3

%N Consider the least base b >= 2 where the sum of digits of n is a prime number; a(n) corresponds to this prime number.

%H Rémy Sigrist, <a href="/A355035/b355035.txt">Table of n, a(n) for n = 2..10000</a>

%F a(n) = A216789(n, A355034(n)).

%e For n = 16:

%e - we have the following expansions and sum of digits:

%e b 16_b Sum of digits in base b

%e - ------- -----------------------

%e 2 "10000" 1

%e 3 "121" 4

%e 4 "100" 1

%e 5 "31" 4

%e 6 "24" 6

%e 7 "22" 4

%e 8 "20" 2

%e - so a(16) = 2.

%o (PARI) a(n) = my (s); for (b=2, oo, if (isprime(s=sumdigits(n,b)), return (s)))

%o (Python)

%o from sympy import isprime

%o from sympy.ntheory.digits import digits

%o def s(n, b): return sum(digits(n, b)[1:])

%o def a(n):

%o b = 2

%o while not isprime(s(n, b)): b += 1

%o return s(n, b)

%o print([a(n) for n in range(2, 89)]) # _Michael S. Branicky_, Jun 16 2022

%Y Cf. A216789, A355034 (corresponding b's).

%K nonn,base

%O 2,1

%A _Rémy Sigrist_, Jun 16 2022