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.

A085063 a(n) is the minimal number k such that n+k and n*k+1 are primes.

Original entry on oeis.org

1, 1, 2, 1, 2, 1, 4, 5, 2, 1, 2, 1, 4, 3, 2, 1, 6, 1, 10, 3, 2, 1, 6, 13, 4, 3, 4, 1, 2, 1, 10, 11, 10, 3, 2, 1, 4, 5, 2, 1, 2, 1, 4, 9, 14, 1, 6, 5, 4, 3, 2, 1, 14, 5, 6, 5, 4, 1, 12, 1, 6, 5, 10, 3, 2, 1, 4, 15, 2, 1, 8, 1, 6, 27, 8, 3, 6, 1, 4, 3, 2, 1, 6, 5, 12, 11, 20, 1, 12, 7, 6, 5, 4, 3, 2, 1, 4, 5
Offset: 1

Views

Author

Amarnath Murthy, Jun 28 2003

Keywords

Comments

If n+1 is prime then a(n)=1; if n+1 is not prime then a(n)=A120223(n).

Examples

			a(3)=2 because 3+2=5 and 3*2+1=7 are prime;
a(8)=5 because 8+5=13 and 8*5+1=41 are prime,
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local k;
    for k from 1+(n mod 2) by 2 do
      if isprime(n+k) and isprime(n*k+1) then return k fi
    od
    end proc:
    f(1):= 1: # Robert Israel, May 14 2018
  • Mathematica
    Reap[Do[Do[If[PrimeQ[{n+x, n*x+1}]=={True,True},Sow[x];Break[]],{x,1,100}],{n,120}]][[2,1]]
    nkp[n_]:=Module[{k=1},While[!And@@PrimeQ[{n+k,n*k+1}],k++];k]; Array[nkp, 100] (* Harvey P. Dale, Apr 11 2012 *)
  • PARI
    a(n) = {my(k=1); while (!isprime(n+k) || !isprime(n*k+1), k++); k;} \\ Michel Marcus, May 14 2018

Extensions

Corrected and extended by Zak Seidov, Jun 10 2006