Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #16 Nov 27 2022 12:13:22
%S 3,1004,3,1004,3,1004,30,349,30,5,19,5,30,1004,30,8,11,8,30,5,86,17,
%T 67,17,15,9,19,9,15,9,19,484,19,13,30,9,19,9,19,13,374,13,19,13,11,
%U 484,86,484,19,13,67,16,19,16,19,484,374,484,19,484,374,24,19,13
%N a(n) is the position m of the last prime term in the sequence {b(m)} defined by b(1) = n, if b(m) is prime then b(m+1) = b(m) - m, else b(m+1) = b(m) + m.
%C A sequence {b(m)} is guaranteed to have no more primes when the m-th term "k" with value "s" is the sum of at least 3 consecutive positive integers where the sum is "s" and the last consecutive positive integer in the sum is k-1. Any number which is the sum of at least three consecutive positive integers is guaranteed to be composite. By the definition of the sequence, the next term k + 1 = s + k, and this term will be the sum of at least three consecutive positive integers with the last consecutive positive integer being k. This guarantees that this term is also guaranteed to be composite, and by induction, all future terms in {b(m)} will be composite.
%C In a sequence {b(m)}, if the m-th term k with value s satisfies c = (sqrt(-8*s + 4*k^2 - 4*k + 1) + 1)/2 for a positive integer c with s being nonprime and k > 3 then the value of all terms >= k will be composite.
%C It is unknown whether all initial conditions "n" guarantee a final prime. All terms up to n = 1000 have a final prime.
%C Treat negative numbers in the sequence {b(m)} as nonprime. The only n whose {b(m)} contain negative terms b(m) are 1, 3, 6, and 7.
%H Samuel Harkness, <a href="/A358269/b358269.txt">Table of n, a(n) for n = 0..1111</a>
%e For n = 9: b(1) = 9. Nonprime, b(2) = 9 + 1 = 10. Nonprime, b(3) = 10 + 2 = 12. Nonprime, b(4) = 12 + 3 = 15. Nonprime, b(5) = 15 + 4 = 19. Prime, b(6) = 19 - 5 = 14. Note 14 = 2 + 3 + 4 + 5 and is nonprime, so b(7) = 2 + 3 + 4 + 5 + 6 and nonprime. All b(m) after this will be nonprime by the same pattern, thus the final prime for b(1) = 9 occurs at b(5), and a(9) = 5.
%t T = {}; For[f = 0, f <= 63, f++, a = 0; t = f; q = 0; While[a == 0, q++; If[t < 0, t += q, If[PrimeQ[t], t -= q; If[t >= 0, If[q != 2 && q != 1 && ! PrimeQ[t], s = t; k = q + 1; z = (Sqrt[-8 s + 4 k^2 - 4 k + 1] + 1)/2; If[Element[z, Reals] && z > 0 && Mod[z, 1] == 0, AppendTo[T, q]; Break[]]]], t += q]]]]; Print[T]
%Y Cf. A074171, A358166
%Y Examples of sequences of the sum of consecutive positive integers, where the sum of at least three is guaranteed to be composite: A055999, A212427.
%K nonn
%O 0,1
%A _Samuel Harkness_, Nov 06 2022