OFFSET
1,3
COMMENTS
The Collatz problem with negative numbers is as follows: start with any number n = -1, -2, -3, ... If n is even, divide it by 2, otherwise multiply it by 3 and add 1. Do we always reach a last number of each cycle? It is conjectured that the answer is yes.
A majority of last numbers of each cycle is -1, but it is possible to obtain also -5, -10, -14, -20, -34,....
LINKS
Michel Lagneau, Table of n, a(n) for n = 1..10000
EXAMPLE
a(10) = 4 because the trajectory of -10 is -10 -> -5 -> -14 -> -7 -> -20 -> -10 and -10 is the last term of the cycle, hence 4 iterations.
MAPLE
printf(`%d, `, 1): for n from -2 by -1 to -100 do:x:=n:lst:={n}:for it from 1 to 100 do:if irem(x, 2)=0 then x := x/2: lst:=lst union{x} :else x := 3*x+1: lst:=lst union{x}fi:od:d:=nops(lst): printf(`%d, `, d-1): od:
MATHEMATICA
Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, UnsameQ, All]; Table[s = Collatz[-n]; len = Length[s] - 2; If[s[[-1]] == 2, len = len - 1]; len, {n, 1, 100}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Apr 01 2013
EXTENSIONS
a(1) changed to 1 by Pontus von Brömssen, Jan 24 2021
STATUS
approved