A355035 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, 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, 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, 3, 7, 2, 3, 3, 5, 3, 7, 3, 5, 2, 3, 3, 3, 3, 3, 5, 5, 3
Offset: 2
Examples
For n = 16: - we have the following expansions and sum of digits: b 16_b Sum of digits in base b - ------- ----------------------- 2 "10000" 1 3 "121" 4 4 "100" 1 5 "31" 4 6 "24" 6 7 "22" 4 8 "20" 2 - so a(16) = 2.
Links
- Rémy Sigrist, Table of n, a(n) for n = 2..10000
Programs
-
PARI
a(n) = my (s); for (b=2, oo, if (isprime(s=sumdigits(n,b)), return (s)))
-
Python
from sympy import isprime from sympy.ntheory.digits import digits def s(n, b): return sum(digits(n, b)[1:]) def a(n): b = 2 while not isprime(s(n, b)): b += 1 return s(n, b) print([a(n) for n in range(2, 89)]) # Michael S. Branicky, Jun 16 2022