login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Number of steps required to reach 1 for repeated applications of the Collatz-inspired function f(n) = 6*n+5-(n mod 5), or -1 if 1 is never reached.
0

%I #19 May 11 2021 06:13:48

%S 0,7,5,3,1,12,31,10,29,8,27,8,8,25,6,6,23,19,19,4,21,17,17,36,2,19,15,

%T 15,34,13,129,17,13,13,32,30,32,127,15,11,11,13,144,28,30,125,13,30,

%U 13,9,11,142,26,11,28,123,11,28,11,9,140,9,140,24,9,9,28,121

%N Number of steps required to reach 1 for repeated applications of the Collatz-inspired function f(n) = 6*n+5-(n mod 5), or -1 if 1 is never reached.

%C Inspired by the Collatz conjecture, I tried to generalize for more divisors than 2. I quickly came up with a formula, and then discovered that Carnielliy had written about it previously in 2015.

%H Carnielliy, Walter. <a href="https://www.emis.de/journals/AMEN/2015/AMEN(150711).pdf">Some Natural Generalizations Of The Collatz Problem</a>, Applied Mathematics E-Notes, 2015, page 208.

%o (Python)

%o def f(n, d):

%o """

%o A Collatz-like function.

%o When d == 2 this becomes '3x+1' problem exactly.

%o """

%o r = n % d

%o if r == 0:

%o return n // d

%o else:

%o # Produce a larger number that is divisible by d.

%o return (d + 1) * n + d - r

%o def steps(n, d):

%o """

%o Return the number of steps needed to reach 1, or -1 if a 1 is never reached.

%o """

%o count = 0

%o seen = set([1])

%o x = n

%o # Loop until a cycle is detected.

%o while x not in seen:

%o seen.add(x)

%o x = f(x, d)

%o count += 1

%o if x == 1:

%o return count

%o else:

%o # There was a cycle

%o return -1

%o # Create a bunch of terms for d=5

%o S = [steps(x, d=5) for x in range(1, 1000)]

%o print(S)

%Y If you replace d=5 with d=2, this code produces A006577.

%K nonn

%O 1,2

%A _Matt Donahoe_, Aug 22 2020