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!)
A330443 Least m >= 0 such that (n+m)(n+m+1)/2 - n(n-3)/2 is prime, or -1 if no such m exists. 1

%I #37 Jan 02 2023 12:30:54

%S 2,0,1,-1,1,2,1,2,5,7,1,2,1,3,1,7,2,2,10,2,1,10,1,10,1,2,1,7,5,3,13,2,

%T 1,19,1,3,1,2,5,7,2,2,1,10,2,7,1,2,10,2,1,7,1,3,1,2,2,7,5,2,1,3,2,10,

%U 1,2,1,2,5,10,1,10,10,15,1,22,1,2,10

%N Least m >= 0 such that (n+m)(n+m+1)/2 - n(n-3)/2 is prime, or -1 if no such m exists.

%C a(n) + 1 is the number of steps to reach a prime in the game described by Peter Luschny on the SeqFan list (cf. link): Start with n, then add n, n+1, n+2, ..., n+m until a prime is reached.

%C See A330501 for the resulting prime, A329946 for the primes never reached.

%C Among the first 200 terms a(0..199), there are 50 '1's, 49 '2's, 19 '3's and 19 '10's, and 17 '7's. Is there an explanation for the frequency of, e.g., 10?

%H Peter Luschny, <a href="http://list.seqfan.eu/oldermail/seqfan/2019-December/">Hopping for primes</a>, SeqFan list, Dec 13 2019.

%F a(n) = A330502(n) - n.

%e Starting with n = 0, add 0: sum = 0, not prime, then add 1: sum = 1, not prime, then add 2: sum = 3, a prime, so a(0) = 2.

%e Starting with n = 1, add 1: sum = 2, a prime, so a(1) = 2 - 2 = 0.

%e Starting with n = 2, add 2: sum = 4, not prime, then add 3: sum = 7, a prime, so a(2) = 3 - 2 = 1.

%e Starting with n = 3 = T(2) = 2(2+1)/2 (triangular number, cf. A000217), add 3 to get T(2) + 3 = T(3) = 6, then add 4 to get T(3) + 4 = T(4) = 10, and so on. A triangular number T(n) = n(n+1)/2 > 3 is never prime, since either product of n and (n+1)/2, or product of n/2 and n+1. So a(3) = -1.

%t Array[If[# == 3, 0, Block[{m = #}, While[! PrimeQ[m (m + 1)/2 - # (# - 3)/2], m++]; m-#]] &, 72, 0] (* following code from _Michael De Vlieger_ in A330502 *)

%o (PARI) apply( {A330443(n)=max(A330502(n)-n,-1)}, [0..199])

%Y Cf. A000217 (triangular numbers n(n+1)/2), A000096 (n(n+3)/2), A330501 (the final prime reached), A330502 (a(n)+n), A329946 (primes never reached).

%K sign

%O 0,1

%A _M. F. Hasler_, following an idea of _Peter Luschny_, Dec 16 2019

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 25 11:24 EDT 2024. Contains 371967 sequences. (Running on oeis4.)