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.

A103689 a(n) is the least k such that either k*n - 1 or k*n + 1 (or both) is prime.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1, 4, 2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 1, 6, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 6, 1, 6, 1, 2, 2, 2, 1, 4, 1, 2, 1, 4, 1, 4, 1, 2, 2, 4, 1, 2, 1, 2, 1, 2, 1, 6, 2, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 1, 6, 1, 6, 1, 2
Offset: 1

Views

Author

Pierre CAMI, Feb 12 2005

Keywords

Crossrefs

Programs

  • Haskell
    a103689 n = min (a053989 n) (a034693 n)
    -- Reinhard Zumkeller, Feb 14 2013
    
  • Mathematica
    f[n_] := Block[{k = 1}, While[ ! PrimeQ[k*n - 1] && ! PrimeQ[k*n + 1], k++ ]; k]; Table[ f[n], {n, 105}] (* Robert G. Wilson v, Feb 12 2005 *)
    lk[n_]:=Module[{k=1},While[NoneTrue[k*n+{1,-1},PrimeQ],k++];k]; Array[ lk,120] (* The program uses the NoneTrue function from Mathematica version 10 *) (* Harvey P. Dale, May 01 2016 *)
  • PARI
    a(n) = my(k=1); while (!isprime(k*n+1) && !isprime(k*n-1), k++); k; \\ Michel Marcus, Oct 18 2021

Formula

a(n) <= A200996(n). - Reinhard Zumkeller, Feb 14 2013
a(n) = min {A053989(n), A034693(n)}. - Reinhard Zumkeller, Feb 14 2013
a(A002110(n)/3+3) >= ceiling((prime(n+1)-1)/3) for n >= 2. Equality holds for n = 2, 4, 6, 8, 10, 12, 22, 25, 31, 116, 155, 156, 197, ... . - Pontus von Brömssen, Oct 16 2021
a(A002110(n)/3-3) >= ceiling((prime(n+1)-1)/3) for n >= 3. Equality holds for n = 3, 4, 5, 6, 7, 9, 39, 51, 59, 65, 98, 311, ... . - Pontus von Brömssen, Oct 19 2021

Extensions

Edited, corrected and extended by Robert G. Wilson v, Feb 19 2005