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-2 of 2 results.

A226178 Exponents n such that 2^n - previous_prime(2^n) = next_prime(2^n) - 2^n.

Original entry on oeis.org

2, 6, 12, 76, 181, 1099, 1820, 9229
Offset: 1

Views

Author

Jean-François Alcover, May 30 2013

Keywords

Comments

The differences next_prime(2^n) - 2^n are respectively: 1, 3, 3, 15, 165, 1035, 663, 2211.
If it exists, a(9) > 10000. - Hugo Pfoertner, Feb 06 2021

Examples

			2^6 = 64, next prime = 67, previous prime = 61, 67-64 = 64-61 = 3, hence 6 is in the sequence.
		

Crossrefs

Programs

  • Mathematica
    Reap[Do[m = 2^n; p = NextPrime[m, -1]; q = NextPrime[m]; If[p + q == 2*m, Print[n]; Sow[n]], {n, 2, 10^4}]][[2, 1]]
  • PARI
    isok(n) = my(p=2^n); p-precprime(p-1) == nextprime(p+1) - p; \\ Michel Marcus, Oct 02 2019
    
  • PARI
    for(n=2,1100,my(p2=2^n,pn=nextprime(p2),pp=p2-pn+p2);if(ispseudoprime(pp),if(precprime(p2)==pp,print1(n,", ")))) \\ Hugo Pfoertner, Feb 06 2021
    
  • Python
    from itertools import count, islice
    from sympy import isprime, nextprime
    def A226178_gen(): # generator of terms
        return filter(lambda n:isprime(r:=((k:=1<A226178_list = list(islice(A226178_gen(),5)) # Chai Wah Wu, Aug 08 2022

Formula

A340707(a(n)) = 0. - Hugo Pfoertner, Feb 06 2021

Extensions

Offset 1 from Michel Marcus, Oct 02 2019
a(8) from Hugo Pfoertner, Feb 05 2021

A356434 Prime nearest to 2^n. In case of a tie, choose the larger.

Original entry on oeis.org

2, 2, 5, 7, 17, 31, 67, 127, 257, 509, 1021, 2053, 4099, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573, 2097143, 4194301, 8388617, 16777213, 33554467, 67108859, 134217757, 268435459, 536870909, 1073741827, 2147483647, 4294967291, 8589934583
Offset: 0

Views

Author

Peter Munn, Aug 07 2022

Keywords

Crossrefs

A117387 differs by preferring the smaller prime in the case of a tie, which occurs when n is in A226178.

Programs

  • Mathematica
    Join[{2,2},Table[Max[Nearest[{NextPrime[2^n,-1],NextPrime[2^n]},2^n]],{n,2,40}]] (* Harvey P. Dale, Feb 19 2023 *)
  • Python
    from sympy import prevprime, nextprime
    def A356434(n): return (r if (m:=nextprime(k:=1< (k<<1)-(r:=prevprime(k)) else m) if n>1 else 2 # Chai Wah Wu, Aug 08 2022

Formula

a(0) = 2; for n >= 1, if A014210(n) + A014234(n) > 2^(n+1) then a(n) = A014234(n), otherwise a(n) = A014210(n).
Showing 1-2 of 2 results.