A367479 a(n) is the number of steps required for prime(n) to reach 2 when iterating the following hailstone map: If P == 5 (mod 6), then P -> next_prime(P + ceiling(sqrt(P))), otherwise P -> previous_prime(ceiling(sqrt(P))); or a(n) = -1 if prime(n) never reaches 2.
0, 1, 8, 2, 7, 2, 6, 9, 5, 4, 9, 3, 5, 3, 5, 4, 4, 3, 3, 5, 3, 3, 4, 11, 3, 10, 8, 9, 8, 9, 8, 5, 5, 8, 4, 3, 3, 3, 4, 5, 4, 3, 4, 3, 4, 3, 3, 3, 15, 3, 15, 9, 3, 14, 8, 9, 13, 7, 7, 8, 7, 12, 7, 11, 7, 11, 10, 10, 11, 10, 11, 11
Offset: 1
Keywords
Examples
For n=1, prime(1)=2, requires a(1)=0 steps to reach 2. For n=2, prime(2)=3, requires a(2)=1 step: 3 -> 2. For n=3, prime(3)=5, requires a(3)=8 steps: 5 -> 11 -> 17 -> 23 -> 29 -> 37 -> 7 -> 3 -> 2.
Programs
-
Python
from sympy import nextprime, prevprime from math import isqrt def hailstone(prime): if (prime + 1) % 6 == 0: jump = prime + isqrt(prime-1) + 1 jump = nextprime(jump - 1) else: jump = isqrt(prime-1) + 1 jump = prevprime(jump + 1) return jump def a(n): p = nextprime(1,n) count = 0 while p != 2: p = hailstone(p) count += 1 return count
Comments