OFFSET
4,2
COMMENTS
If n = s*t is composite with s <= t-2, then n = s * (t-1) + s is a two-digit palindrome in base t-1, while s^2 = (s-1)^2 + 2 * (s-1) + 1 is a palindrome in base s-1. Thus a(n) >= sqrt(n)-1 for composite n > 6. On the other hand, there may be infinitely many primes for which a(n) = 0 (see A016038).
LINKS
Robert Israel, Table of n, a(n) for n = 4..10000
EXAMPLE
a(10) = 7 because 10 = 101_3 = 22_4 is a palindrome in bases 3 and 4, and 3 + 4 = 7.
MAPLE
ispali:= proc(x, b) local F; F:= convert(x, base, b);
andmap(t -> F[t] = F[-t], [$1.. nops(F)/2])
end proc:
f:= proc(k) convert(select(b -> ispali(k, b), [$2..k-2]), `+`) end proc:
map(f, [$4 .. 100]);
PROG
(Python)
from sympy.ntheory import is_palindromic
def a(n): return sum(b for b in range(2, n-2) if is_palindromic(n, b))
print([a(n) for n in range(4, 86)]) # Michael S. Branicky, Oct 15 2024
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Robert Israel, Oct 15 2024
STATUS
approved