A358269 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.
3, 1004, 3, 1004, 3, 1004, 30, 349, 30, 5, 19, 5, 30, 1004, 30, 8, 11, 8, 30, 5, 86, 17, 67, 17, 15, 9, 19, 9, 15, 9, 19, 484, 19, 13, 30, 9, 19, 9, 19, 13, 374, 13, 19, 13, 11, 484, 86, 484, 19, 13, 67, 16, 19, 16, 19, 484, 374, 484, 19, 484, 374, 24, 19, 13
Offset: 0
Keywords
Examples
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.
Links
- Samuel Harkness, Table of n, a(n) for n = 0..1111
Crossrefs
Programs
-
Mathematica
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]
Comments