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.

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.

This page as a plain text file.
%I A385613 #8 Jul 14 2025 17:00:23
%S A385613 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,
%T A385613 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,
%U A385613 4,5,5,6,9,10,9,10,15,9,4,22,4,5,5,6,4,11,4
%N 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.
%C A385613 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.
%C A385613 No other loop is found for n < 164901049.
%C A385613 Conjecture: a(n) = -1 occurs only when starting number n runs into a loop.
%e A385613 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.
%e A385613 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.
%o A385613 (Python)
%o A385613 from sympy import isprime
%o A385613 def A385613(n):
%o A385613     S = {n}
%o A385613     while n != 0:
%o A385613         n = n//3 if n%2 == 0 else n*n - 1 if isprime(n) else n - 1
%o A385613         if n in S: return -1
%o A385613         S.add(n)
%o A385613     return len(S) - 1
%Y A385613 Cf. A339991, A340801, A384713.
%K A385613 sign
%O A385613 0,4
%A A385613 _Ya-Ping Lu_, Jul 04 2025