|
|
A139391
|
|
Next odd term in Collatz trajectory with starting value n.
|
|
26
|
|
|
1, 1, 5, 1, 1, 3, 11, 1, 7, 5, 17, 3, 5, 7, 23, 1, 13, 9, 29, 5, 1, 11, 35, 3, 19, 13, 41, 7, 11, 15, 47, 1, 25, 17, 53, 9, 7, 19, 59, 5, 31, 21, 65, 11, 17, 23, 71, 3, 37, 25, 77, 13, 5, 27, 83, 7, 43, 29, 89, 15, 23, 31, 95, 1, 49, 33, 101, 17, 13, 35, 107, 9, 55, 37, 113, 19, 29
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
LINKS
|
|
|
FORMULA
|
|
|
MATHEMATICA
|
a[n_]:=Select[NestWhileList[If[EvenQ[#], #/2, 3#+1] &, n, #>1 &], OddQ]; Prepend[Table[If[EvenQ[n], a[n][[1]], a[n][[2]]], {n, 2, 77}], 1] (* Jayanta Basu, May 27 2013 *)
|
|
PROG
|
(Python) # first formula
def A006370(n): return 3*n+1 if n%2 else n//2
def a(n): return x if (x := A006370(n))%2 else a(x)
(Python) # fourth formula, uses A006370 above
while n%2 == 0: n //= 2
return n
(PARI) a(n) = my(x = if(n%2, 3*n+1, n/2)); x/2^valuation(x, 2); \\ Michel Marcus, Feb 27 2022
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|