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.

A385613 Number of steps that n requires to reach 0 under the map: x-> x^2 - 1 if x is an odd prime, floor(x/3) if x is even, otherwise x - 1. a(n) = -1 if 0 is never reached.

Original entry on oeis.org

0, 1, 1, 3, 2, 4, 2, 7, 2, 3, 4, 9, 3, 6, 3, 4, 5, 8, 3, 10, 3, 4, 8, 14, 3, 4, 3, 4, 4, 10, 5, 15, 5, 6, 10, 11, 4, 10, 4, 5, 7, 8, 4, 14, 4, 5, 5, 10, 6, 7, 6, 7, 9, 15, 4, 5, 4, 5, 11, 9, 4, 18, 4, 5, 5, 6, 9, 10, 9, 10, 15, 9, 4, 22, 4, 5, 5, 6, 4, 11, 4
Offset: 0

Views

Author

Ya-Ping Lu, Jul 04 2025

Keywords

Comments

n = 122827 is the smallest starting number that ends up in a loop. The loop contains 33 elements: 122827 -> 15086471928 -> 5028823976 -> 1676274658 -> 558758219 -> 558758218 -> 186252739 -> 186252738 -> 62084246 -> 20694748 -> 6898249 -> 47585839266000 -> 15861946422000 -> 5287315474000 -> 1762438491333 -> 1762438491332 -> 587479497110 -> 195826499036 -> 65275499678 -> 21758499892 -> 7252833297 -> 7252833296 -> 2417611098 -> 805870366 -> 268623455 -> 268623454 -> 89541151 -> 89541150 -> 29847050 -> 9949016 -> 3316338 -> 1105446 -> 368482 -> 122827.
No other loop is found for n < 164901049.
Conjecture: a(n) = -1 occurs only when starting number n runs into a loop.

Examples

			a(5) = 4 because iterating the map on n = 5 results in 0 in 4 steps: 5 -> 5^2-1=24 -> floor(24/3)=8 -> floor(8/3)=2 -> floor(2/3)=0.
a(9949031) = -1 because iterating the map on n = 9949031 ends up in the 33-member loop in 5 steps: 9949031 -> 9949030 -> 3316343 -> 3316342 -> 1105447 -> 1105446.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    def A385613(n):
        S = {n}
        while n != 0:
            n = n//3 if n%2 == 0 else n*n - 1 if isprime(n) else n - 1
            if n in S: return -1
            S.add(n)
        return len(S) - 1
Showing 1-1 of 1 results.