OFFSET
0,4
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.
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
sign
AUTHOR
Ya-Ping Lu, Jul 04 2025
STATUS
approved
