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.

A308918 a(n) is the number of palindromic numbers with 7 digits in base n which are also palindromic in base n+1.

This page as a plain text file.
%I A308918 #17 Jul 05 2019 03:01:05
%S A308918 0,0,1,2,7,8,13,18,27,35,50,61,75,79,96,113,120,150,173,180,204,227,
%T A308918 245,274,295,318,346,363,398,438,448,484,524,537,584,625,648,707,749,
%U A308918 771,830,882,914,983,1041,1073,1143,1207,1238,1307,1372,1405,1480,1544,1573,1645
%N A308918 a(n) is the number of palindromic numbers with 7 digits in base n which are also palindromic in base n+1.
%C A308918 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).
%C A308918 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).
%C A308918 If m has at least 7 digits in base n, it seems that a(n) is of order O(n^2*log(n)).
%o A308918 (Python)
%o A308918 def nextpal(n,base): # m is the first palindrome successor of n in base base
%o A308918     m, pl = n+1, 0
%o A308918     while m > 0:
%o A308918         m, pl = m//base, pl+1
%o A308918     if n+1 == base**pl:
%o A308918         pl = pl+1
%o A308918     n = n//(base**(pl//2))+1
%o A308918     m, n = n, n//(base**(pl%2))
%o A308918     while n > 0:
%o A308918         m, n = m*base+n%base, n//base
%o A308918     return m
%o A308918 def ispal(n,b):
%o A308918     if n%b == 0:
%o A308918         return 0
%o A308918     else:
%o A308918         nn, m = n, 0
%o A308918         while n > 0:
%o A308918             n, m = n//b, m*b+n%b
%o A308918         return m == nn
%o A308918 n, d = 1, 7
%o A308918 while n < 20000:
%o A308918     n = n+1
%o A308918     p = n**(d-1)-1
%o A308918     a = 0
%o A308918     while p < n**d:
%o A308918         p = nextpal(p,n+1)
%o A308918         if ispal(p,n):
%o A308918             a = a+1
%o A308918     print(n,a)
%o A308918 (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
%o A308918 ispal(n, b) = my(d=digits(n, b)); Vecrev(d) == d;
%o A308918 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
%Y A308918 Cf. A048268.
%K A308918 nonn,base
%O A308918 2,4
%A A308918 _A.H.M. Smeets_, Jun 30 2019