cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A375387 #43 Sep 03 2024 01:36:31
%S A375387 -1,130,41,123,16,170,-1,55,155,39,274,239,96,187,494,2925,685,1784,
%T A375387 1389,859,599,1779,1978,989,6597,5887,6968,8499,5989,17969,29859,
%U A375387 17899,28898,435897,38989,2089469,1788960,498847,2886278,487878,919996,4098689,898794,1896967
%N 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.
%C A375387 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 A375387 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 A375387 From _Michael S. Branicky_, Aug 15 2024: (Start)
%C A375387 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 A375387 Computer search shows no such terms with d <= 10^6, so a(2), if it exists, has > 10^6 decimal digits. (End)
%H A375387 Michael S. Branicky, <a href="/A375387/b375387.txt">Table of n, a(n) for n = 3..149</a>
%H A375387 Michael S. Branicky, <a href="/A375387/a375387.py.txt">Python programs for OEIS A375387</a>
%H A375387 Jean-Marc Rebert, <a href="/A375387/a375387.txt">a375387_1e10</a>
%e A375387 a(5) = 41, because 4 + 1 = 5 and 41 = 131_5, and no lesser number has this property.
%e A375387 First terms are:
%e A375387   130 = 2002_4
%e A375387   41  = 131_5
%e A375387   123 = 3323_6
%e A375387   16  = 22_7
%e A375387   170 = 252_8
%o A375387 (PARI) isok(k, n) = if (sumdigits(k)==n, my(d=digits(k, n)); d==Vecrev(d));
%o A375387 a(n) = if ((n==3) || (n==9), return((-1))); my(k=1); while (!isok(k,n), k++); k; \\ _Michel Marcus_, Aug 13 2024
%o A375387 (Python) # see Links for faster variants
%o A375387 from itertools import count
%o A375387 from sympy.ntheory import is_palindromic
%o A375387 def a(n):
%o A375387     if n in {3, 9}: return -1
%o A375387     return next(k for k in count(10**(n//9)-1) if sum(map(int, str(k)))==n and is_palindromic(k, n))
%o A375387 print([a(n) for n in range(3, 47)]) # _Michael S. Branicky_, Aug 13 2024
%Y A375387 Cf. A002113, A007953, A051885, A065531, A107129, A228915, A253594.
%K A375387 sign,base
%O A375387 3,2
%A A375387 _Jean-Marc Rebert_, Aug 13 2024