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

%I #17 Jul 05 2019 03:01:05

%S 0,0,1,2,7,8,13,18,27,35,50,61,75,79,96,113,120,150,173,180,204,227,

%T 245,274,295,318,346,363,398,438,448,484,524,537,584,625,648,707,749,

%U 771,830,882,914,983,1041,1073,1143,1207,1238,1307,1372,1405,1480,1544,1573,1645

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

%C 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 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 If m has at least 7 digits in base n, it seems that a(n) is of order O(n^2*log(n)).

%o (Python)

%o def nextpal(n,base): # m is the first palindrome successor of n in base base

%o m, pl = n+1, 0

%o while m > 0:

%o m, pl = m//base, pl+1

%o if n+1 == base**pl:

%o pl = pl+1

%o n = n//(base**(pl//2))+1

%o m, n = n, n//(base**(pl%2))

%o while n > 0:

%o m, n = m*base+n%base, n//base

%o return m

%o def ispal(n,b):

%o if n%b == 0:

%o return 0

%o else:

%o nn, m = n, 0

%o while n > 0:

%o n, m = n//b, m*b+n%b

%o return m == nn

%o n, d = 1, 7

%o while n < 20000:

%o n = n+1

%o p = n**(d-1)-1

%o a = 0

%o while p < n**d:

%o p = nextpal(p,n+1)

%o if ispal(p,n):

%o a = a+1

%o print(n,a)

%o (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 ispal(n, b) = my(d=digits(n, b)); Vecrev(d) == d;

%o 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 Cf. A048268.

%K nonn,base

%O 2,4

%A _A.H.M. Smeets_, Jun 30 2019

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 May 6 02:22 EDT 2024. Contains 372290 sequences. (Running on oeis4.)