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.

A280631 Starting position (after the decimal point) of the first n-digit palindrome in the decimal expansion of Pi.

Original entry on oeis.org

0, 24, 1, 43, 19, 762, 640, 3732, 6577, 16061, 247146, 273840, 879326, 5380812, 10593200, 171880711, 105176740, 517694394, 559015193, 824827924
Offset: 1

Views

Author

Bobby Jacobs, Jan 06 2017

Keywords

Comments

The first 10-digit palindrome in the decimal expansion of Pi (0136776310) first appears at a palindromic position (16061).

Examples

			a(2) = 24 because the first 2-digit palindrome in the decimal expansion of Pi (33) starts 24 digits after the decimal point.
3.14159265358979323846264(33)...
		

Crossrefs

Programs

  • Mathematica
    With[{d = First@ RealDigits@ N[Pi, 10^6]}, Prepend[DeleteCases[Rest@ #, 0], First@ #] &@ Flatten@ Map[If[Length@ # == 0, 0, #[[1, 1]] - 1] &@ SequencePosition[d, #] &, Table[If[Length@ # == 0, {}, First@ #] &@ Select[Partition[d, n, 1], # == Reverse@ # &], {n, 20}]]] (* Michael De Vlieger, Jan 07 2017, Version 10.1 *)
  • Python
    from sympy import S
    # download https://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt, then
    # with open('pi-billion.txt', 'r') as f: pi_digits = f.readline()
    pi_digits = str(S.Pi.n(3*10**5+2))[:-2] # alternative to above
    pi_digits = pi_digits.replace(".", "")
    def ispal(s): return s == s[::-1]
    def a(n):
        for idx in range(len(pi_digits)-n):
            if ispal(pi_digits[idx:idx+n]):
                return int(pi_digits[idx:idx+n]), idx
        return None, None # Not found: Increase number of digits
    print([a(n)[1] for n in range(1, 13)]) # Michael S. Branicky, Jan 10 2022

Extensions

a(14)-a(15) from Michael De Vlieger, Jan 07 2017
a(16)-a(20) from Michael S. Branicky, Jan 10 2022