cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-1 of 1 results.

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.

Original entry on oeis.org

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

Views

Author

Najeem Ziauddin, Nov 19 2023

Keywords

Comments

next_prime(x) is the next prime >= x, and previous_prime(x) is the next prime <= x.
Conjecture: This hailstone operation on prime numbers will always reach 2.
The map does not go into a loop for any starting prime.

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.
		

Crossrefs

Cf. A007528.
Similar sequence: A365048.

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
Showing 1-1 of 1 results.