This site is supported by donations to The OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A033479 3x+1 sequence beginning at 9. 5

%I

%S 9,28,14,7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,4,2,1,4,2,

%T 1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,

%U 4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1,4,2,1

%N 3x+1 sequence beginning at 9.

%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>

%e 9 is odd, so the next term is 3*9 + 1 = 28.

%e 28 is even, so the next term is 28/2 = 14.

%t NestList[If[EvenQ[#], #/2, 3# + 1] &, 9, 100] (* _Harvey P. Dale_, Dec 16 2012 *)

%o (Scala) def collatz(n: Int): Int = (n % 2) match {

%o case 0 => n / 2

%o case 1 => 3 * n + 1

%o }

%o import scala.collection.mutable.ListBuffer

%o val start = 9; var curr = start; var trajectory = new ListBuffer[Int]()

%o for (_ <- 1 to 100) {

%o trajectory += curr; curr = collatz(curr)

%o }

%o trajectory // _Alonso del Arte_, Jun 02 2019

%Y Cf. A070165.

%K nonn

%O 0,1

%A _Jeff Burch_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified June 25 17:47 EDT 2019. Contains 324353 sequences. (Running on oeis4.)