The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A360097 a(n) = smallest k such that 2*n*k-1 and 2*n*k+1 are nonprimes. 2
13, 14, 20, 7, 5, 10, 4, 4, 8, 6, 7, 5, 1, 2, 4, 2, 1, 4, 2, 3, 17, 4, 2, 3, 1, 4, 4, 1, 2, 2, 2, 1, 8, 3, 8, 2, 4, 1, 8, 2, 3, 11, 1, 2, 10, 1, 1, 3, 4, 3, 2, 2, 4, 2, 2, 5, 3, 1, 1, 1, 1, 1, 9, 4, 2, 4, 1, 4, 3, 4, 1, 1, 1, 2, 2, 2, 1, 4, 3, 1, 2, 2, 4, 7, 1 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
EXAMPLE
We try 1..k until the condition is met:
a(7) != 1 because 2*7*1 = 14 and 14 - 1 = 13, a prime.
a(7) != 2 because 2*7*2 = 28 and 28 + 1 = 29, a prime.
a(7) != 3 because 2*7*3 = 42 and 42 - 1 = 41 and 42 + 1 = 43, both primes.
a(7) = 4 because 2*7*4 = 56 and 56 - 1 = 55 and 56 + 1 = 57 are both nonprimes.
MAPLE
f:= proc(n) local k;
for k from 1 do
if not isprime(2*n*k-1) and not isprime(2*n*k+1) then return k fi
od
end proc:
map(f, [$1..100]); # Robert Israel, Feb 07 2023
MATHEMATICA
a[n_] := Module[{k = 1}, While[PrimeQ[2*n*k - 1] || PrimeQ[2*n*k + 1], k++]; k]; Array[a, 100] (* Amiram Eldar, Jan 25 2023 *)
PROG
(Python)
from sympy import isprime
from itertools import count
def a(n): return next(k for k in count(1) if not isprime(2*n*k-1) and not isprime(2*n*k+1))
print([a(n) for n in range(1, 86)]) # Michael S. Branicky, Jan 25 2023
(PARI) a(n) = my(k=1); while(isprime(2*n*k-1) || isprime(2*n*k+1), k++); k; \\ Michel Marcus, Jan 25 2023
CROSSREFS
Sequence in context: A241749 A098045 A293817 * A360258 A360528 A336004
KEYWORD
nonn
AUTHOR
Tamas Sandor Nagy, Jan 25 2023
EXTENSIONS
More terms from Michael S. Branicky, Jan 25 2023
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 20 10:42 EDT 2024. Contains 372712 sequences. (Running on oeis4.)