OFFSET
0,1
COMMENTS
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.
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?
LINKS
Peter Luschny, Hopping for primes, SeqFan list, Dec 13 2019.
FORMULA
a(n) = A330502(n) - n.
EXAMPLE
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.
Starting with n = 1, add 1: sum = 2, a prime, so a(1) = 2 - 2 = 0.
Starting with n = 2, add 2: sum = 4, not prime, then add 3: sum = 7, a prime, so a(2) = 3 - 2 = 1.
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.
MATHEMATICA
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 *)
CROSSREFS
KEYWORD
sign
AUTHOR
M. F. Hasler, following an idea of Peter Luschny, Dec 16 2019
STATUS
approved