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.

A377758 a(n) is the least i such that 2n-prime(i) is also a prime, where prime(i) is the i-th prime.

Original entry on oeis.org

1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 3, 4, 2, 2, 3, 4, 2, 3, 2, 2, 3, 2, 3, 4, 2, 3, 4, 2, 2, 3, 4, 2, 3, 2, 2, 3, 4, 2, 3, 2, 3, 4, 2, 3, 4, 8, 2, 3, 2, 2, 3, 2, 2, 3, 2, 3, 4, 6, 5, 6, 8, 2, 3, 2, 3, 4, 2, 2, 3, 4, 5, 5, 2, 2, 3, 4, 2, 3, 4, 2, 3, 2, 3
Offset: 2

Views

Author

Keywords

Crossrefs

Programs

  • Maple
    f:= proc(n) local i,p;
      p:= 1:
      for i from 1 do
        p:= nextprime(p);
        if isprime(2*n-p) then return i fi
      od
    end proc:
    map(f, [$2..100]); # Robert Israel, Nov 19 2024
  • Mathematica
    Table[Module[{i = 1}, While[i <= PrimePi[n] && ! PrimeQ[n - Prime[i]], i++]; If[i <= PrimePi[n], i, None]], {n, 4, 1000, 2}]
  • PARI
    a(n) = my(i=1); while (!isprime(2*n-prime(i)), i++); i; \\ Michel Marcus, Nov 06 2024
    
  • Python
    from sympy import primerange, isprime
    def A377758(n): return next(i for i, p in enumerate(primerange(2*n),1) if isprime((n<<1)-p)) # Chai Wah Wu, Nov 19 2024

Formula

a(n) = pi(A020481(n)).