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, 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
Examples
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
Links
- Michael S. Branicky, Table of n, a(n) for n = 3..149
- Michael S. Branicky, Python programs for OEIS A375387
- Jean-Marc Rebert, a375387_1e10
Programs
-
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
Comments