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.

Showing 1-3 of 3 results.

A332929 Position where the binary expansion of n occurs for the first time in the binary expansion of Pi.

Original entry on oeis.org

3, 1, 2, 1, 2, 18, 1, 13, 8, 2, 21, 18, 1, 17, 16, 13, 8, 27, 2, 62, 25, 21, 18, 93, 49, 1, 20, 17, 95, 16, 15, 13, 97, 8, 27, 45, 2, 128, 62, 146, 25, 60, 21, 395, 229, 18, 93, 209, 49, 65, 1, 78, 42, 20, 17, 105, 95, 116, 186, 16, 175, 15, 14, 13, 97, 110
Offset: 0

Views

Author

Thomas König, Mar 02 2020

Keywords

Examples

			In binary, Pi = 11.00100100.... The bitstring 10 (for 2) occurs at position 2, so a(2) = 2.
		

Crossrefs

Cf. A032445 (for decimal expansion rather than binary).

Programs

  • Mathematica
    p = RealDigits[Pi,2,500][[1]]; L = {}; Do[t = SequencePosition[p, IntegerDigits[n, 2], 1]; If[t == {}, Break[], AppendTo[L, t[[1, 1]]]], {n, 0, 65}]; L (* Giovanni Resta, Mar 16 2020 *)
    Module[{nn=500,bp},bp=RealDigits[Pi,2,nn][[1]];Table[ SequencePosition[ bp,IntegerDigits[n,2],1][[All,1]],{n,0,70}]]//Flatten (* Harvey P. Dale, Sep 18 2021 *)
  • Perl
    #! /usr/bin/perl
    # Feed b004601.txt to this to get the binary digits of Pi.
    while (<>) {
        chomp;
        (undef, $d[$n++]) = split(" ");
    }
    $pi = join("",@d);
    $k = 0;
    while (1) {
        last if ($pos = index($pi, sprintf("%b", $k++))) < 0;
        $out .= $pos +2 . ", ";
    }
    print $out,"\n";

A382667 Position of the first instance of prime(n), in base 2, in the binary representation of Pi after the binary point.

Original entry on oeis.org

3, 11, 16, 11, 16, 15, 25, 60, 91, 14, 11, 126, 58, 393, 207, 18, 14, 13, 6, 180, 141, 169, 58, 243, 47, 326, 168, 475, 15, 291, 451, 108, 64, 87, 327, 421, 358, 41, 356, 468, 343, 16, 618, 107, 80, 179, 57, 206, 291, 325, 361, 205, 427, 12, 95, 108, 436, 6, 996
Offset: 1

Views

Author

James S. DeArmon, Apr 02 2025

Keywords

Comments

Positions are numbered starting from 1 for the first bit after the binary point in Pi.

Examples

			For n=19, the bits of Pi and their numbering, after the binary point, begin
          1 2 3 4 5 6 7 8 9 ...
   1 1 .  0 0 1 0 0 1 0 0 0 0 1 1 1 1 ...
                    \-----------/
                    prime(19) = 67
prime(19) = 1000011_2 begins at position a(19) = 6.
prime(58) = 271 = 100001111_2 also starts at 6 => a(58) = 6.
		

Crossrefs

Programs

  • Mathematica
    p=Drop[RealDigits[Pi,2,1010][[1]],2](* increase for n>73 *);a[n_]:=First[SequencePosition[p,IntegerDigits[Prime[n],2]][[1]]] (* James C. McMahon, Apr 26 2025 *)
  • Python
    import gmpy2
    from sympy import isprime
    gmpy2.get_context().precision = 12000000
    gmpy2.get_context().round = gmpy2.RoundDown
    pi = gmpy2.const_pi()
    binary_pi = gmpy2.digits(pi, 2)[0][2:] # Get binary digits and remove "11"
    print([binary_pi.find(bin(cand)[2:])+1 for cand in range(2, 700) if isprime(cand)])

Formula

a(n) = A178707(A000040(n)). - Pontus von Brömssen, Apr 12 2025

A383502 Position of the first instance of prime(n), in base 3, in the ternary representation of Pi after the ternary point.

Original entry on oeis.org

2, 4, 6, 2, 12, 20, 6, 10, 27, 16, 85, 3, 35, 78, 95, 6, 38, 96, 19, 27, 9, 66, 157, 171, 81, 191, 12, 127, 52, 3, 36, 275, 88, 589, 283, 40, 290, 952, 47, 10, 1213, 750, 572, 84, 126, 2, 282, 162, 125, 480, 26, 66, 185, 157, 1490, 1310, 832, 1321, 352
Offset: 1

Views

Author

James S. DeArmon, Apr 28 2025

Keywords

Comments

Positions are numbered starting from 1 for the first ternary digit after the ternary point in Pi.

Examples

			The ternary digits of Pi and their numbering, after the ternary point, begin
          1 2 3 4 5 6 7 8 9 ...
   0 1  . 0 2 1 1 0 1 2 2 2 2 0 1 0 2 ...
                    \---/
prime(7) is 17, or 122_3, which first appears at position 6.
		

Crossrefs

Programs

  • Python
    import gmpy2
    from sympy import isprime
    def to_base3(n):
        if n == 0: return '0'
        d = []
        while n: d.append(str(n % 3)); n //= 3
        return ''.join(reversed(d))
    gmpy2.get_context().precision = 1200000
    pi_ternary = gmpy2.digits(gmpy2.const_pi(),3)[0][4:]  # skip "10."
    out = []
    for p in range(2, 280):
        if isprime(p):
            pos = pi_ternary.find(to_base3(p)) + 1
            out.append(pos)
    print(out)
Showing 1-3 of 3 results.