cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A232503 Largest power of 2 in the Collatz (3x+1) trajectory of n.

This page as a plain text file.
%I A232503 #23 Aug 18 2017 09:48:20
%S A232503 1,2,16,4,16,16,16,8,16,16,16,16,16,16,16,16,16,16,16,16,64,16,16,16,
%T A232503 16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,64,16,16,16,16,16,
%U A232503 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,64,16,16,16,16
%N A232503 Largest power of 2 in the Collatz (3x+1) trajectory of n.
%C A232503 All terms are powers of 4 (A000302) unless n is an odd-indexed power of 2 (A004171), as explained in one of the comments for A135282. - _Alonso del Arte_, Nov 26 2013
%H A232503 Antti Karttunen, <a href="/A232503/b232503.txt">Table of n, a(n) for n = 1..1024</a>
%H A232503 <a href="/index/3#3x1">Index entries related to the 3x+1 (Collatz) problem</a>
%F A232503 a(n) = 2^A135282(n). - _Antti Karttunen_, Aug 18 2017
%e A232503 a(8) = 8 because then there are only halving steps and thus 8 is the largest power of 2 in its Collatz trajectory.
%e A232503 a(9) = 16 because the Collatz sequence for 9 goes 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 (see A033479) and the largest power of 2 there is 16.
%t A232503 Collatz[n_?OddQ] := 3n + 1; Collatz[n_?EvenQ] := n/2; Table[NestWhile[Collatz, n, Not[IntegerQ[Log[2, #]]] &], {n, 64}] (* _Alonso del Arte_, Nov 26 2013 based on _T. D. Noe_'s program for A135282 *)
%t A232503 Table[With[{p2=2^Range[0,10]},Select[NestWhileList[If[EvenQ[#], #/2, 3#+1]&, n,#>1&], MemberQ[ p2,#]&]]//Max,{n,70}] (* _Harvey P. Dale_, May 07 2016 *)
%o A232503 (Scheme)
%o A232503 (define (A232503 n) (let loop ((n n) (m 1)) (if (= 1 n) m (loop (A006370 n) (if (= 1 (A209229 n)) (max n m) m)))))
%o A232503 (define (A006370 n) (if (even? n) (/ n 2) (+ 1 n n n)))
%o A232503 ;; _Antti Karttunen_, Aug 18 2017
%Y A232503 Cf. A006370, A135282, A226123.
%K A232503 nonn
%O A232503 1,2
%A A232503 _Lance Luttrell_, Nov 24 2013