login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A319586 Number of n-digit base-10 palindromes (A002113) that cannot be written as the sum of two positive base-10 palindromes. 1
2, 0, 8, 7, 95, 94, 975, 971, 9810, 9805, 98288, 98272 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
EXAMPLE
a(1) = 2, because 0 and 1 are not sums of two positive 1-digit integers, all of which are palindromes. a(3) = 8, because the 8 3-digit palindromes 111, 131, 141, 151, 161, 171, 181, and 191 (A213879(2) ... A213879(9)) cannot be written as sum of two nonzero palindromes.
PROG
(PARI) \\ calculates a(2)...a(8) using M. F. Hasler's functions in A002113
A002113(n)={my(L=logint(n, 10)); (n-=L=10^max(L-(n<11*10^(L-1)), 0))*L+fromdigits(Vecrev(digits(if(n<L, n, n\10))))}
is_A002113(n)={Vecrev(n=digits(n))==n}
inv_A002113(P)={P\(P=10^(logint(P+!P, 10)\/2))+P}
for(i=1, 8, j=0; for(m=inv_A002113(10^i+1), inv_A002113(2*(10^i+1)), P=A002113(m); issum=0; for(k=2, m, PP=A002113(k); if(PP>P/2, break); if(is_A002113(P-PP), issum=1; break)); if(issum==0, j++)); print1(j, ", ", ))
(Python)
from sympy import isprime
from itertools import product
def pals(d, base=10): # all d-digit palindromes
digits = "".join(str(i) for i in range(base))
for p in product(digits, repeat=d//2):
if d > 1 and p[0] == "0": continue
left = "".join(p); right = left[::-1]
for mid in [[""], digits][d%2]: yield int(left + mid + right)
def a(n):
palslst = [p for d in range(1, n+1) for p in pals(d)][1:]
palsset = set(palslst)
cs = ctot = 0
for p in pals(n):
ctot += 1
for p1 in palslst:
if p - p1 in palsset: cs += 1; break
if p1 > p//2: break
return ctot - cs
print([a(n) for n in range(1, 8)]) # Michael S. Branicky, Jul 12 2021
CROSSREFS
Sequence in context: A366164 A021483 A011015 * A287467 A288015 A288438
KEYWORD
nonn,base,hard,more
AUTHOR
Hugo Pfoertner, Sep 23 2018
EXTENSIONS
a(12) from Giovanni Resta, Oct 01 2018
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 19 17:46 EDT 2024. Contains 375310 sequences. (Running on oeis4.)