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.

Previous Showing 11-13 of 13 results.

A357746 Primes p such that the least k for which k*p + 1 is prime is also the least k for which k*p - 1 is prime.

Original entry on oeis.org

47, 103, 107, 283, 313, 347, 397, 773, 787, 907, 1051, 1117, 1319, 1433, 1823, 2027, 2153, 2203, 2287, 2333, 2347, 2381, 2909, 3221, 3257, 3673, 3923, 3929, 4129, 4153, 4217, 4547, 4597, 4657, 4721, 4969, 5023, 5387, 5407, 5693, 5717, 5827, 5881, 6373, 6781, 6863, 6997
Offset: 1

Views

Author

Karl-Heinz Hofmann, Jan 01 2023

Keywords

Comments

If A035096(n) = A216568(n) the n-th prime is a term. Here k*p must be the composite number sandwiched between a pair of twin primes, so by Wilson's theorem, k must be a multiple of 6.

Examples

			a(1) = 47: 47*6 + 1 = 283 (a prime), 47*6 - 1 = 281 (also a prime), and no k < 6 gives a prime as the result for both formulas.
		

Crossrefs

Programs

  • Mathematica
    q[p_] := Module[{k = 1, r}, While[! Or @@ (r = PrimeQ[k*p + {-1, 1}]), k++]; And @@ r]; Select[Prime[Range[900]], q] (* Amiram Eldar, Jan 01 2023 *)
  • PARI
    isk(p, x) = my(k=1); while (!isprime(k*p+x), k++); k;
    isok(p) = if (isprime(p), isk(p, +1) == isk(p, -1)); \\ Michel Marcus, Jan 01 2023
  • Python
    from sympy import sieve, isprime
    def leastk(p, plusminus):
        k=1
        while not isprime(k * p + plusminus): k += 1
        return k
    print([p for p in sieve[1:1000] if leastk(p, 1) == leastk(p, -1)])
    

A367805 a(1) = 0; for n > 1, a(n) is the least positive integer k for which k*prime(n) + 2 is prime.

Original entry on oeis.org

0, 1, 1, 3, 1, 3, 1, 3, 3, 1, 5, 3, 1, 3, 7, 7, 1, 5, 5, 1, 5, 3, 3, 3, 3, 1, 3, 1, 5, 9, 3, 7, 1, 3, 1, 5, 5, 3, 3, 3, 1, 5, 1, 5, 1, 3, 9, 5, 1, 9, 3, 1, 15, 7, 3, 15, 1, 9, 11, 1, 9, 3, 21, 1, 3, 3, 5, 3, 1, 3, 3, 15, 3, 5, 9, 3, 13, 3, 19, 3, 1, 15, 1, 3, 3, 9, 13, 3, 1, 15
Offset: 1

Views

Author

Frank Hollstein, Dec 01 2023

Keywords

Examples

			For n = 4: a(4) = 3, because prime(4) = 7, 3*7 + 2 = 23 which is prime.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) local p, q, r; p:= ithprime(n); q:= p;
          while irem(q-2, p, 'r')<>0 do q:= nextprime(q) od; r
        end:
    seq(a(n), n=1..99);  # Alois P. Heinz, Dec 04 2023
  • Mathematica
    nmax=90; a[1]=0; For[n=2, n<=nmax, n++, For[k=1, k>0, k++, If[PrimeQ[k*Prime[n]+2], a[n]=k; k=-1]]]; Array[a,nmax] (* Stefano Spezia, Dec 04 2023 *)
  • PARI
    a(n) = if (n==1, 0, my(k=1, p=prime(n)); while (!isprime(k*p+2), k++); k); \\ Michel Marcus, Dec 02 2023
    
  • Python
    from itertools import count, dropwhile
    from sympy import prime, isprime
    def A367805(n):
        if n==1:
            return 0
        else:
            p = prime(n)
            return next(dropwhile(lambda x:not isprime(x*p+2),count(1))) # Chai Wah Wu, Jan 04 2024

Formula

a(n) = (A279756(n) - 2)/A000040(n).
a(n) = 1 <=> n in A029707.

Extensions

More terms from Michel Marcus, Dec 02 2023

A266239 a(n) is the smallest k such that the following are four primes: prime(n)*k-1, prime(n)*k+1, prime(n)*k^2-1, prime(n)*k^2+1. Or -1 if no such k exists.

Original entry on oeis.org

3, 2, 6, 66, 300, 24, 3744, 27000, 6, 1080, 960, 90, 30, 366, 9204, 8154, 1170, 840, 330, 6090, 84, 27720, 324, 90, 186, 4740, 2856, 6, 24270, 936, 5220, 1560, 6, 1500, 510, 120, 930, 3270, 30, 8520, 29700, 1200, 23310, 1056, 3540, 90, 3420, 2370, 9654, 83040, 2610, 9270, 2610
Offset: 1

Views

Author

Alex Ratushnyak, Dec 25 2015

Keywords

Comments

Conjecture: a(n)>1.

Examples

			a(1)=3 because the following are four primes: 2*3-1, 2*3+1, 2*9-1, 2*9+1.
		

Crossrefs

Programs

  • PARI
    a(n) = {k = 1; p = prime(n); while (! (isprime(p*k-1) && isprime(p*k+1) && isprime(p*k^2-1) && isprime(p*k^2+1)), k++);k;} \\ Michel Marcus, Dec 27 2015
  • Python
    from sympy import isprime
    TOP=10**9
    for p in range(2, 333):
        if isprime(p):
            failed = True
            for x in range(1, TOP):
                if isprime(p*x+1) and isprime(p*x-1) and isprime(p*x*x-1) and isprime(p*x*x+1):
                    print(x, end=', ')
                    failed = False
                    break
            if failed: print(-1, end=', ')
    
Previous Showing 11-13 of 13 results.