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.

A057821 a(n) is the least nonnegative integer k such that 2^n - k is a safe prime.

Original entry on oeis.org

1, 5, 9, 5, 21, 29, 9, 5, 9, 17, 45, 161, 165, 269, 285, 17, 45, 233, 9, 17, 321, 317, 633, 677, 405, 437, 189, 1385, 69, 209, 9, 641, 849, 137, 45, 401, 381, 437, 1965, 2201, 741, 1493, 573, 857, 1485, 5297, 2709, 161, 465, 473, 1269, 4805, 789
Offset: 3

Views

Author

Warren D. Smith, Nov 23 2000

Keywords

Comments

Previous name was: "Useful safe primes: a(n) = least nonnegative integer k such that 2^n - k is prime and (2^n-k-1)/2 is also prime". The resulting sequence of 2^n-k terms: 7, 11, 23, 59, 107, ..., are thus the largest safe primes smaller than 2^n (A243916), a subsequence of A005385. - Michel Marcus, Jan 08 2014

Crossrefs

Programs

  • PARI
    a(n) = {my(k=0); until (isprime(2^n-k) && isprime((2^n-k-1)/2), k++); return (k);} \\ Michel Marcus, Jun 29 2013
    
  • Python
    from sympy import isprime
    def a(n):
        k=0
        while True:
            k+=1
            if isprime(2**n - k) and isprime((2**n - k - 1)//2): return k
    print([a(i) for i in range(3, 21)]) # Indranil Ghosh, Jun 12 2017, after PARI code by Michel Marcus

A350696 a(n) is the least nonnegative integer k such that 2^n + k is a safe prime.

Original entry on oeis.org

1, 3, 7, 15, 19, 39, 7, 51, 163, 15, 31, 231, 103, 75, 7, 195, 499, 99, 127, 627, 955, 555, 691, 87, 679, 99, 1411, 351, 799, 135, 91, 771, 79, 951, 667, 975, 1183, 1311, 667, 315, 955, 759, 2011, 9315, 4243, 1575, 907, 1527, 3943, 2091, 1927, 75, 1879
Offset: 2

Views

Author

Mark Andreas, Jan 12 2022

Keywords

Comments

2^n+a(n) is the smallest (n+1)-bit safe prime.

Examples

			a(6)=19 because 2^6+19=83 is the smallest safe prime greater than 64 of the form p=2q+1 where p and q are both primes.
		

Crossrefs

Programs

  • Mathematica
    safeQ[p_] := And @@ PrimeQ[{p, (p - 1)/2}]; a[n_] := Module[{k = 2^n + 1}, While[! safeQ[k], k++]; k -= 2^n]; Array[a, 50, 2] (* Amiram Eldar, Jan 12 2022 *)
  • PARI
    a(n) = {my(k=0); until (isprime(2^n+k) && isprime((2^n+k-1)/2), k++); return (k); }

A345014 a(n) is the least nonnegative integer k such that 2^n - k is a Sophie Germain prime.

Original entry on oeis.org

0, 1, 3, 5, 3, 11, 15, 5, 3, 5, 9, 23, 81, 83, 135, 143, 9, 23, 117, 5, 9, 161, 159, 317, 339, 203, 219, 95, 693, 35, 105, 5, 321, 425, 69, 23, 201, 191, 219, 983, 1101, 371, 747, 287, 429, 743, 2649, 1355, 81, 233, 237, 635, 2403, 395, 1125, 1997, 69, 9005
Offset: 1

Views

Author

Artsiom Palkounikau, Sep 15 2021

Keywords

Crossrefs

Programs

  • Mathematica
    Table[k=0;While[!(PrimeQ[p=2^n-k]&&PrimeQ[2p+1]),k++];k,{n,58}] (* Giorgos Kalogeropoulos, Sep 15 2021 *)
  • PARI
    a(n) = my(k=0,p); while (!(isprime(p=2^n-k) && isprime(2*p+1)), k++); k; \\ Michel Marcus, Sep 15 2021
  • Python
    from sympy import isprime
    def a(n):
        k = 0
        while True:
            if isprime(2 ** n - k) and isprime(2 * (2 ** n - k) + 1):
                return k
            k += 1
    print([a(i) for i in range(1, 21)])
    

Formula

a(n) = (A057821(n+1) + 1)/2.
Showing 1-3 of 3 results.