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.

A343908 a(n) is the least prime == 4 (mod prime(n)).

Original entry on oeis.org

2, 7, 19, 11, 37, 17, 89, 23, 73, 149, 97, 41, 127, 47, 239, 163, 181, 431, 71, 359, 223, 83, 419, 271, 101, 307, 107, 967, 113, 569, 131, 397, 1237, 421, 2239, 457, 1103, 167, 839, 523, 541, 547, 577, 197, 1777, 601, 1481, 227, 3863, 233, 3499, 2633, 727, 757, 1289, 1319, 811, 1901, 281, 1409
Offset: 1

Views

Author

Zak Seidov, May 03 2021

Keywords

Examples

			a(3) = 19 because 19 is the least prime == 4 (mod prime(3)).
a(4) = 11 because 11 is the least prime == 4 (mod prime(4)).
		

Crossrefs

Cf. A000040, A023200 (primes p such that p+4 is also prime), A034694, A035095, A279756.

Programs

  • Maple
    a:= proc(n) local q, p; p:= ithprime(n); q:= p;
          do if irem(q-4, p)=0 then break fi;
             q:= nextprime(q);
          od; q
        end:
    seq(a(n), n=1..60);  # Alois P. Heinz, May 03 2021
  • Mathematica
    s = {}; p = 5; Do[q = p + 2; While[Mod[q, p] != 4, q = NextPrime[q]]; AppendTo[s, q]; p = NextPrime[p], {100}]; s
  • PARI
    a(n) = my(p=prime(n)); forprime(q=2,, if (Mod(q, p) == 4, return(q))); \\ Michel Marcus, May 03 2021

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