OFFSET
2,4
COMMENTS
If an integer m is palindromic in both bases n and n+1, then m has an odd number of digits in base n (see also A048268).
If m has 1, 3 or 5 digits in base n, the number of integers that are palindromic in bases n and n+1 is of order O(n) (see also A048268).
If m has at least 7 digits in base n, it seems that a(n) is of order O(n^2*log(n)).
PROG
(Python)
def nextpal(n, base): # m is the first palindrome successor of n in base base
m, pl = n+1, 0
while m > 0:
m, pl = m//base, pl+1
if n+1 == base**pl:
pl = pl+1
n = n//(base**(pl//2))+1
m, n = n, n//(base**(pl%2))
while n > 0:
m, n = m*base+n%base, n//base
return m
def ispal(n, b):
if n%b == 0:
return 0
else:
nn, m = n, 0
while n > 0:
n, m = n//b, m*b+n%b
return m == nn
n, d = 1, 7
while n < 20000:
n = n+1
p = n**(d-1)-1
a = 0
while p < n**d:
p = nextpal(p, n+1)
if ispal(p, n):
a = a+1
print(n, a)
(PARI) nextpal(n, b) = {my(m=n+1, p = 0); while (m > 0, m = m\b; p++; ); if (n+1 == b^p, p++); n = n\(b^(p\2))+1; m = n; n = n\(b^(p%2)); while (n > 0, m = m*b + n%b; n = n\b; ); m; } \\ after Python
ispal(n, b) = my(d=digits(n, b)); Vecrev(d) == d;
a(n) = {my(d=7, p = n^(d-1)-1, nb = 0); while (p < n^d, p = nextpal(p, n+1); if (ispal(p, n), nb++); ); nb; } \\ Michel Marcus, Jul 04 2019
CROSSREFS
KEYWORD
nonn,base
AUTHOR
A.H.M. Smeets, Jun 30 2019
STATUS
approved