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!)
A218344 Smallest k such that k*(n-th composite)+1 is prime. 3

%I #19 Jun 07 2022 10:55:32

%S 1,1,2,2,1,1,2,2,1,1,2,2,1,3,4,2,4,1,1,3,2,3,2,1,5,2,1,1,2,4,1,2,4,2,

%T 2,1,2,6,2,4,1,1,5,2,3,2,1,2,2,1,1,2,2,3,6,1,3,2,1,4,12,2,4,1,2,6,3,4,

%U 3,2,1,2,2,1,1,3,2,1,1,3,2,1,2,4,2,8,6,2

%N Smallest k such that k*(n-th composite)+1 is prime.

%H Amiram Eldar, <a href="/A218344/b218344.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from T. D. Noe)

%e The composite numbers are A002808. a(1) is 1 since the first composite number is 4, and 4*1+1=5, a prime. a(14)=3 since the 14th composite is 24, and 24*3+1=73 prime, while 25 and 49 are not.

%t t={}; For[k = 4, k < 200, k++, If[!PrimeQ[k], Mult = 1; While[! PrimeQ[k*Mult + 1], Mult = Mult + 1]; AppendTo[t, Mult]]]; t

%t sk[n_]:=Module[{k=1},While[!PrimeQ[k*n+1],k++];k]; nn=150;With[{cmps= Complement[ Range[4,nn],Prime[Range[PrimePi[nn]]]]},sk/@cmps] (* _Harvey P. Dale_, Apr 16 2013 *)

%o (Python)

%o from sympy import composite, isprime

%o def a(n):

%o cn, k = composite(n), 1

%o while not isprime(k*cn + 1): k += 1

%o return k

%o print([a(n) for n in range(1, 89)]) # _Michael S. Branicky_, Jun 07 2022

%Y Cf. A002808.

%K nonn,easy

%O 1,3

%A _William J. Keith_, Oct 26 2012

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 April 24 13:24 EDT 2024. Contains 371955 sequences. (Running on oeis4.)