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!)
A308918 a(n) is the number of palindromic numbers with 7 digits in base n which are also palindromic in base n+1. 0
0, 0, 1, 2, 7, 8, 13, 18, 27, 35, 50, 61, 75, 79, 96, 113, 120, 150, 173, 180, 204, 227, 245, 274, 295, 318, 346, 363, 398, 438, 448, 484, 524, 537, 584, 625, 648, 707, 749, 771, 830, 882, 914, 983, 1041, 1073, 1143, 1207, 1238, 1307, 1372, 1405, 1480, 1544, 1573, 1645 (list; graph; refs; listen; history; text; internal format)
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)).
LINKS
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
Cf. A048268.
Sequence in context: A231625 A032927 A004717 * A226819 A270104 A063531
KEYWORD
nonn,base
AUTHOR
A.H.M. Smeets, Jun 30 2019
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 April 24 04:14 EDT 2024. Contains 371918 sequences. (Running on oeis4.)