OFFSET
1,2
LINKS
Ryan Pythagoras Newton Critchlow, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
For n = 2, the 2nd triangular number is 3, which takes 7 steps to reach 1 in the Collatz (3x+1) problem: (10, 5, 16, 8, 4, 2, 1).
MATHEMATICA
Table[Length[NestWhileList[If[EvenQ[#], #/2, 3#+1]&, n, #>1&]]-1, {n, Accumulate[ Range[80]]}] (* Harvey P. Dale, Aug 17 2017 *)
PROG
(Python 3)
num = 1
def triangleN(x):
return x*(x+1)/2
def stepCount(x):
x = int(x)
steps = 0
while True:
if x == 1:
break
elif x % 2 == 0:
x = x/2
steps += 1
else:
x = x*3 + 1
steps += 1
return steps
while True:
print(stepCount(triangleN(num)))
num += 1
CROSSREFS
KEYWORD
nonn
AUTHOR
Ryan Pythagoras Newton Critchlow, Jun 04 2017
STATUS
approved