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.

A093868 Smallest prime that differs from a multiple of n by unity.

Original entry on oeis.org

2, 3, 2, 3, 11, 5, 13, 7, 17, 11, 23, 11, 53, 13, 29, 17, 67, 17, 37, 19, 41, 23, 47, 23, 101, 53, 53, 29, 59, 29, 61, 31, 67, 67, 71, 37, 73, 37, 79, 41, 83, 41, 173, 43, 89, 47, 281, 47, 97, 101, 101, 53, 107, 53, 109, 113, 113, 59, 353, 59, 367, 61, 127, 127, 131, 67, 269
Offset: 1

Views

Author

Amarnath Murthy, Apr 20 2004

Keywords

Comments

Numbers n such that a(n-1)=a(n+1)=n are A025584 (primes p such that p-2 is not a prime). - Rick L. Shepherd, Aug 23 2004

Crossrefs

Cf. A093869.
Cf. A034694 (Smallest prime == 1 (mod n)), A038700 (Smallest prime == -1 (mod n)).

Programs

  • Maple
    f:= proc(n) local j,k;
      for k from 1 do
        for j in [-1,1] do
          if isprime(k*n+j) then return k*n+j fi
      od od
    end proc:
    map(f, [$1..100]); # Robert Israel, Nov 07 2019
  • Mathematica
    a[n_] := Module[{p}, For[p = 2, True, p = NextPrime[p], If[Divisible[p-1, n] || Divisible[p+1, n], Return[p]]]];
    Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Feb 04 2023 *)
  • PARI
    a(n) = forprime(p=2, , if (!((p+1) % n) || !((p-1) % n), return (p))); \\ Michel Marcus, Aug 08 2014

Formula

a(n) = min(A034694(n), A038700(n)) for all n >= 1. - Rick L. Shepherd, Aug 23 2004

Extensions

More terms from Rick L. Shepherd, Aug 23 2004