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

%I #30 Oct 21 2021 17:37:31

%S 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,

%T 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,

%U 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

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

%H Reinhard Zumkeller, <a href="/A103689/b103689.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) <= A200996(n). - _Reinhard Zumkeller_, Feb 14 2013

%F a(n) = min {A053989(n), A034693(n)}. - _Reinhard Zumkeller_, Feb 14 2013

%F 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

%F 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

%t 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 *)

%t 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 *)

%o (Haskell)

%o a103689 n = min (a053989 n) (a034693 n)

%o -- _Reinhard Zumkeller_, Feb 14 2013

%o (PARI) a(n) = my(k=1); while (!isprime(k*n+1) && !isprime(k*n-1), k++); k; \\ _Michel Marcus_, Oct 18 2021

%Y Cf. A002110, A034693, A053989, A103688, A200996, A348347.

%K easy,nonn

%O 1,5

%A _Pierre CAMI_, Feb 12 2005

%E Edited, corrected and extended by _Robert G. Wilson v_, Feb 19 2005