OFFSET
1,3
COMMENTS
The analog of A139399 for negative starting values.
Is a(n) > -1 for all n?
a(n) is also the number of steps it takes +n to reach a cycle in the map A001281. - Rhys Feltman, Dec 01 2025
FORMULA
EXAMPLE
For n = 5: The trajectory of -5 starts -5, -14, -7, -20, -10, -5, -14, -7, -20, -10, -5, ..., with -5 already being part of the cycle {-5, -14, -7, -20, -10}, so a(5) = 0.
For n = 6: The trajectory of -6 starts -6, -3, -8, -4, -2, -1, -2, -1, -2, -1, -2, ..., reaching a term of the cycle {-2, -1} after 4 steps, so a(6) = 4.
PROG
(PARI) a006370(n) = if(n%2==0, n/2, 3*n+1)
trajectory(n, terms) = my(v=[n]); while(#v < terms, v=concat(v, a006370(v[#v]))); v
a(n) = my(t, v=[]); for(k=1, oo, t=trajectory(-n, k); for(x=1, #t, if(x < #t && t[x]==t[#t], return(x-1))))
(Python)
def a(n):
x, traj, seen = -n, [], set()
while x not in seen:
seen.add(x)
traj.append(x)
x = x>>1 if x&1 == 0 else 3*x+1
return traj.index(x)
print([a(n) for n in range(1, 82)]) # Michael S. Branicky, Dec 07 2025
CROSSREFS
KEYWORD
sign
AUTHOR
Felix Fröhlich, Jul 14 2021
STATUS
approved
