OFFSET
1,1
COMMENTS
Collatz stopping time is defined as the number of steps that a number n takes to converge to 1 using one of the following steps:
0) if n is 1, stop.
1) if n is even, divide n by 2 (n/2).
2) if n is odd, multiply n by 3 and add 1 (3n+1).
Subsequence of A006877. The first tie occurs at a(10) which is tied with 9780657631. - Jens Kruse Andersen, Feb 23 2021
LINKS
Gary T. Leavens and Mike Vermeulen, 3x+1 Search Programs, Computers & Mathematics with Applications. 24 (11): 79-99 (1992).
Eric Roosendaal, 3x+1 delay records
FORMULA
a(n) = max{i} (steps(i) for i in range from 1 to 10^n-1).
max(i) returns the i with the maximum steps(i) value.
where steps(n) is defined as follows
steps(n)= 0 if n=1.
1+steps(n/2) if n is even.
1+steps(3*n+1) if n is odd.
EXAMPLE
For n=1, steps(1) to steps(9) take the following values: 0, 1, 7, 2, 5, 8, 16, 3, 19; the maximum of all those is 19 which occurs for steps(9) therefore a(1)=9.
MATHEMATICA
Table[Last@Ordering@Array[If[#>1, #0@If[OddQ@#, 3#+1, #/2]+1, 0]&, 10^k], {k, 4}] (* Giorgos Kalogeropoulos, Apr 01 2021 *)
PROG
(Python 3.4)
def steps(n):
if n==1:
return 0
else:
if (n%2)==0:
return 1+steps(int(n/2))
else:
return 1+steps(3*n+1)
def max_steps(i):
a=max([[i, steps(i)] for i in range(1, 10**(i))], key=lambda x:x[1])
return a[0]
CROSSREFS
KEYWORD
nonn
AUTHOR
Rahul Chand, Apr 01 2017
EXTENSIONS
Clarified and extended by Jens Kruse Andersen, Feb 23 2021
STATUS
approved