Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #43 Sep 03 2024 01:36:31
%S -1,130,41,123,16,170,-1,55,155,39,274,239,96,187,494,2925,685,1784,
%T 1389,859,599,1779,1978,989,6597,5887,6968,8499,5989,17969,29859,
%U 17899,28898,435897,38989,2089469,1788960,498847,2886278,487878,919996,4098689,898794,1896967
%N 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.
%C A positive integer that is a multiple of 3 ends with 0 in base 3, so it cannot be a palindrome in base 3.
%C A positive integer that is a multiple of 9 ends with 0 in base 9, so it cannot be a palindrome in base 9.
%C From _Michael S. Branicky_, Aug 15 2024: (Start)
%C 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.
%C Computer search shows no such terms with d <= 10^6, so a(2), if it exists, has > 10^6 decimal digits. (End)
%H Michael S. Branicky, <a href="/A375387/b375387.txt">Table of n, a(n) for n = 3..149</a>
%H Michael S. Branicky, <a href="/A375387/a375387.py.txt">Python programs for OEIS A375387</a>
%H Jean-Marc Rebert, <a href="/A375387/a375387.txt">a375387_1e10</a>
%e a(5) = 41, because 4 + 1 = 5 and 41 = 131_5, and no lesser number has this property.
%e First terms are:
%e 130 = 2002_4
%e 41 = 131_5
%e 123 = 3323_6
%e 16 = 22_7
%e 170 = 252_8
%o (PARI) isok(k, n) = if (sumdigits(k)==n, my(d=digits(k, n)); d==Vecrev(d));
%o a(n) = if ((n==3) || (n==9), return((-1))); my(k=1); while (!isok(k,n), k++); k; \\ _Michel Marcus_, Aug 13 2024
%o (Python) # see Links for faster variants
%o from itertools import count
%o from sympy.ntheory import is_palindromic
%o def a(n):
%o if n in {3, 9}: return -1
%o return next(k for k in count(10**(n//9)-1) if sum(map(int, str(k)))==n and is_palindromic(k, n))
%o print([a(n) for n in range(3, 47)]) # _Michael S. Branicky_, Aug 13 2024
%Y Cf. A002113, A007953, A051885, A065531, A107129, A228915, A253594.
%K sign,base
%O 3,2
%A _Jean-Marc Rebert_, Aug 13 2024