login
A279909
Number of steps to reach 1 or a cycle in the Collatz-like problem '3x/2' and '(x-1)/2'.
1
0, 2, 1, 3, 3, 3, 2, 8, 3, 4, 4, 7, 4, 6, 3, 11, 9, 6, 4, 15, 5, 12, 5, 11, 8, 6, 5, 7, 7, 14, 4, 18, 11, 10, 10, 11, 7, 9, 5, 11, 16, 6, 6, 15, 13, 12, 6, 17, 12, 9, 9, 11, 7, 11, 6, 19, 8, 8, 8, 11, 15, 14, 5, 24, 19, 14, 11, 13, 11, 13, 11, 16, 12, 8, 8, 10, 10, 10, 6, 16, 11, 17, 17, 18, 7, 26, 7, 24, 16, 11, 14, 13, 13, 15, 7, 23, 18, 14, 13, 23
OFFSET
1,2
COMMENTS
This Collatz-like problem is as follows: start with any number n. If n is even, divide it by 2 and multiply by 3, otherwise subtract 1 and divide it by 2.
The iteration always reach {1} or the cycles {4, 6, 9} and {16 , 24 , 36 , 54 , 81 , 40 , 60 , 90 , 135 , 67 , 33}.
PROG
(Python)
def a(n):
if n==1: return 0
l=[n, ]
while True:
if n%2==0: n=(n/2)*3
else: n = (n - 1)/2
if not n in l:
l+=[n, ]
if n<2: break
else: break
if l[-1]==1: return len(l)-1
return len(l)
for n in range(1, 20001):
print str(n)+" "+str(a(n)) # Indranil Ghosh, Apr 13 2017
CROSSREFS
Cf. A006577.
Sequence in context: A325495 A048865 A058754 * A125087 A271373 A307558
KEYWORD
nonn,easy
AUTHOR
Luca Petrone, Apr 11 2017
STATUS
approved