login
A375387
a(n) is the least number k whose sum of digits in base 10 is n and that is palindromic in base n, or -1 if no such number exists.
1
-1, 130, 41, 123, 16, 170, -1, 55, 155, 39, 274, 239, 96, 187, 494, 2925, 685, 1784, 1389, 859, 599, 1779, 1978, 989, 6597, 5887, 6968, 8499, 5989, 17969, 29859, 17899, 28898, 435897, 38989, 2089469, 1788960, 498847, 2886278, 487878, 919996, 4098689, 898794, 1896967
OFFSET
3,2
COMMENTS
A positive integer that is a multiple of 3 ends with 0 in base 3, so it cannot be a palindrome in base 3.
A positive integer that is a multiple of 9 ends with 0 in base 9, so it cannot be a palindrome in base 9.
From Michael S. Branicky, Aug 15 2024: (Start)
Regarding a(2): To be a palindrome in base 2, it must end with 1, hence odd. To be odd and have digit sum 2 in base 10, it must be of the form t_d = 10^(d-1) + 1, d > 1 (a d-digit base-10 number). t_d is not divisible by 3, and base-2 palindromes with even length (i.e., number of binary digits) are divisible by 3, so, if a(2) exists, it must be a base-2 palindrome with odd length.
Computer search shows no such terms with d <= 10^6, so a(2), if it exists, has > 10^6 decimal digits. (End)
LINKS
Michael S. Branicky, Table of n, a(n) for n = 3..149
Jean-Marc Rebert, a375387_1e10
EXAMPLE
a(5) = 41, because 4 + 1 = 5 and 41 = 131_5, and no lesser number has this property.
First terms are:
130 = 2002_4
41 = 131_5
123 = 3323_6
16 = 22_7
170 = 252_8
PROG
(PARI) isok(k, n) = if (sumdigits(k)==n, my(d=digits(k, n)); d==Vecrev(d));
a(n) = if ((n==3) || (n==9), return((-1))); my(k=1); while (!isok(k, n), k++); k; \\ Michel Marcus, Aug 13 2024
(Python) # see Links for faster variants
from itertools import count
from sympy.ntheory import is_palindromic
def a(n):
if n in {3, 9}: return -1
return next(k for k in count(10**(n//9)-1) if sum(map(int, str(k)))==n and is_palindromic(k, n))
print([a(n) for n in range(3, 47)]) # Michael S. Branicky, Aug 13 2024
KEYWORD
sign,base
AUTHOR
Jean-Marc Rebert, Aug 13 2024
STATUS
approved