(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 7012, 231] NotebookOptionsPosition[ 6146, 198] NotebookOutlinePosition[ 6551, 215] CellTagsIndexPosition[ 6508, 212] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Project - 3x+1 Puzzle", "Title", CellChangeTimes->{{3.4496813196580153`*^9, 3.449681342612208*^9}, { 3.449681664233629*^9, 3.449681669564416*^9}}], Cell[CellGroupData[{ Cell["Overview", "Subsection"], Cell[TextData[{ "Start with any natural number ", StyleBox["n", "Input"], ". If ", StyleBox["n", "Input"], " is even, replace ", StyleBox["n", "Input"], " by ", StyleBox["n/2", "Input"], ". If ", StyleBox["n", "Input"], " is odd, replace ", StyleBox["n", "Input"], " by ", StyleBox["3n+1", "Input"], ". Repeat. " }], "Text", CellChangeTimes->{{3.449681685691018*^9, 3.4496818122929792`*^9}, { 3.449681863081514*^9, 3.449681877261354*^9}, {3.4496819471672487`*^9, 3.4496819523968487`*^9}, {3.449682391562849*^9, 3.449682393534548*^9}}], Cell[TextData[{ "For example, starting with ", StyleBox["n=", "Input"], StyleBox["3,", "Input"], " we get the sequence" }], "Text", CellChangeTimes->{{3.449681882499133*^9, 3.449681897708103*^9}, { 3.449681958819693*^9, 3.449681983252335*^9}, {3.449682103698412*^9, 3.44968212019699*^9}, {3.449682515029481*^9, 3.449682539677046*^9}}], Cell[BoxData[ RowBox[{"3", ",", "10", ",", "5", ",", "16", ",", "8", ",", "4", ",", "2", ",", "1", ",", "4", ",", "2", ",", "1", ",", "4", ",", "2", ",", "1", ",", "4", ",", "2", ",", "1", ",", "..."}]], "Input", CellChangeTimes->{{3.449682124100134*^9, 3.449682142280629*^9}, { 3.44968239951478*^9, 3.449682412009082*^9}}], Cell[TextData[{ "Starting with ", StyleBox["n=7", "Input"], ", we get" }], "Text", CellChangeTimes->{{3.449682504877307*^9, 3.449682536236156*^9}}], Cell[BoxData[ RowBox[{"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", ",", "1", ",", "..."}]], "Input", CellChangeTimes->{{3.4496825803089123`*^9, 3.4496826163828*^9}}], Cell[TextData[{ "In both of these examples, the sequence eventually becomes", StyleBox[" 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, ...", "Input"], "Whether this is true for all starting values is unknown. It has been \ checked for many millions of starting values, but so far no one has proved \ that such sequences always eventually get to ", StyleBox["1", "Input"], ". This is known as the ", StyleBox["3x+1", "Input"], " puzzle. " }], "Text", CellChangeTimes->{{3.449682651135425*^9, 3.449682720322865*^9}, { 3.44968275809055*^9, 3.449682767338457*^9}, 3.449682937916497*^9, { 3.449684084037856*^9, 3.4496842088825912`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Details", "Subsection"], Cell[TextData[{ StyleBox["Step 1:", FontWeight->"Bold"], " Create a ", StyleBox["Mathematica", FontSlant->"Italic"], " command ", StyleBox["f[n]", "Input"], "that takes as input a natural number ", StyleBox["n", "Input"], " and returns the next number in the sequence. For example, ", StyleBox["f[3]=10", "Input"], ", ", StyleBox["f[7]=22", "Input"], "." }], "Text", CellChangeTimes->{{3.4496851392714233`*^9, 3.44968522014034*^9}}], Cell[TextData[{ StyleBox["Step 2:", FontWeight->"Bold"], " Create a ", StyleBox["Mathematica", FontSlant->"Italic"], " command ", StyleBox["seq[n]", "Input"], " that takes as input a natural number ", StyleBox["n", "Input"], " and returns the sequence generated by ", StyleBox["n", "Input"], " until the first ", StyleBox["1", "Input"], " appears. From the above, ", StyleBox["seq[3]={3, 10, 5, 16, 8, 4, 2, 1}", "Input"], " and ", StyleBox["seq[7]={7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, \ 1}", "Input"], "." }], "Text", CellChangeTimes->{{3.4496827981279917`*^9, 3.44968297611619*^9}, { 3.449683012392686*^9, 3.449683041147787*^9}, {3.449685112168666*^9, 3.449685116590356*^9}, {3.449685241710486*^9, 3.449685403683313*^9}}], Cell[TextData[{ StyleBox["Step 3:", FontWeight->"Bold"], " Create a ", StyleBox["Mathematica", FontSlant->"Italic"], " command ", StyleBox["stop[n]", "Input"], " that takes as input a natural number ", StyleBox["n", "Input"], " and returns the number of steps needed until the first ", StyleBox["1", "Input"], ". From the above, ", StyleBox["stop[3]=7", "Input"], " and ", StyleBox["stop[7]=17", "Input"], ". It is probably more efficient not to use ", StyleBox["seq[n]", "Input"], " in the definition of ", StyleBox["stop[n]", "Input"], " so as to avoid having to store long lists.\n", StyleBox["Step 4:", FontWeight->"Bold"], " Make a table of ", StyleBox["n", "Input"], " versus ", StyleBox["stop[n] ", "Input"], "for ", StyleBox["n=1,2,...,100. ", "Input"], "Make the table as pretty as possible." }], "Text", CellChangeTimes->{{3.4496827981279917`*^9, 3.44968297611619*^9}, { 3.449683012392686*^9, 3.449683041147787*^9}, {3.449685112168666*^9, 3.449685116590356*^9}, {3.449685241710486*^9, 3.449685262781999*^9}, { 3.449685419881796*^9, 3.449685454070368*^9}, {3.44968551871843*^9, 3.4496856430054893`*^9}, {3.449685712922621*^9, 3.449685800438096*^9}}], Cell[TextData[{ StyleBox["Step 5: ", FontWeight->"Bold"], "Which number less than ", StyleBox["10000", "Input"], " generates the longest possible sequence? Show the ", StyleBox["Mathematica", FontSlant->"Italic"], " commands you use to answer this question." }], "Text", CellChangeTimes->{{3.4496858751192093`*^9, 3.449685939190402*^9}, { 3.4496860241764174`*^9, 3.449686036561187*^9}}] }, Open ]] }, Open ]] }, WindowSize->{847, 541}, WindowMargins->{{230, Automatic}, {Automatic, 104}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, FrontEndVersion->"6.0 for Mac OS X PowerPC (32-bit) (April 20, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 155, 2, 76, "Title"], Cell[CellGroupData[{ Cell[770, 29, 30, 0, 34, "Subsection"], Cell[803, 31, 555, 19, 26, "Text"], Cell[1361, 52, 344, 8, 26, "Text"], Cell[1708, 62, 333, 5, 27, "Input"], Cell[2044, 69, 151, 5, 26, "Text"], Cell[2198, 76, 387, 5, 27, "Input"], Cell[2588, 83, 629, 13, 56, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3254, 101, 29, 0, 34, "Subsection"], Cell[3286, 103, 449, 16, 41, "Text"], Cell[3738, 121, 772, 23, 56, "Text"], Cell[4513, 146, 1203, 35, 71, "Text"], Cell[5719, 183, 399, 11, 26, "Text"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)