%I #10 May 09 2021 12:47:14
%S 0,1,9,2,7,2,5,2,10,10,5,10,5,10,8,3,5,3,13,3,13,3,13,3,16,8,8,8,13,8,
%T 8,8,11,8,11,3,26,3,21,3,6,3,8,3,8,3,8,3,16,6,16,6,16,6,16,6,6,6,16,6,
%U 16,6,6,3,6,3,16,3,21,3,6,3,11,3,11,3,29,3
%N Number of steps to reach 1 in the 'x^3+1' problem (a variation of the Collatz problem), or -1 if 1 is never reached.
%C The x^3+1 map, which is a variation of the 3x+1 (Collatz) map, is defined for x >= 0 as follows: if x is odd, then map x to x^3+1; otherwise, map x to floor(sqrt(x)).
%C It seems that all x^3+1 trajectories reach 1; this has been verified up to 10^10.
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>
%e For n = 3, a(3) = 9, because there are 9 steps from 3 to 1 in the following trajectory for 3: 3, 28, 5, 126, 11, 1332, 36, 6, 2, 1.
%e For n = 4, a(4) = 2, because there are 2 steps from 4 to 1 in the following trajectory for 4: 4, 2, 1.
%o (Python)
%o from math import floor, sqrt
%o def a(n):
%o if n == 1: return 0
%o count = 0
%o while True:
%o if (n % 2) == 0: n = int(floor(sqrt(n)))
%o else: n = n**3 + 1
%o count += 1
%o if n == 1: break
%o return count
%o print([a(n) for n in range(1, 101)])
%Y Cf. A006370 (image of n under the 3x+1 map).
%Y Cf. A336911 (image of n under the x^3+1 map).
%K nonn
%O 1,3
%A _Robert C. Lyons_, Aug 07 2020
|