login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A336914 Number of steps to reach 1 in '3^x+1' problem (a variation of the Collatz problem), or -1 if 1 is never reached. 1

%I

%S 0,1,4,2,11,2,9,5,7,5,7,5,5,5,16,3,5,3,5,3,16,3,14,3,9,3,14,3,9,3,9,

%T 12,14,12,22,12,14,12,7,12,5,12,5,12,7,12,5,12,7,12,5,12,5,12,20,12,5,

%U 12,16,12,5,12,14,3,12,3,5,3,14,3,5,3,14,3,5,3,5

%N Number of steps to reach 1 in '3^x+1' problem (a variation of the Collatz problem), or -1 if 1 is never reached.

%C The 3^x+1 map, which is a variation of the 3x+1 (Collatz) map, is defined for x >= 1 as follows: if x is odd, then map x to 3^x+1; otherwise, map x to floor(log_2(x)).

%C It seems that all 3^x+1 trajectories reach 1; this has been verified up to 10^9.

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>

%e For n = 5, a(5) = 11, because there are 11 steps from 5 to 1 in the following trajectory for 5: 5, 244, 7, 2188, 11, 177148, 17, 129140164, 26, 4, 2, 1.

%e For n = 6, a(6) = 2, because there are 2 steps from 6 to 1 in the following trajectory for 6: 6, 2, 1.

%o (Python)

%o from math import floor, log

%o def a(n):

%o if n == 1: return 0

%o count = 0

%o while True:

%o if n % 2: n = 3**n + 1

%o else: n = int(floor(log(n, 2)))

%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. A336913 (image of n under the 3^x+1 map).

%K nonn

%O 1,3

%A _Robert C. Lyons_, Aug 08 2020

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 29 09:31 EDT 2021. Contains 346344 sequences. (Running on oeis4.)