(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 8.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 3441, 102] NotebookOptionsPosition[ 3158, 88] NotebookOutlinePosition[ 3503, 103] CellTagsIndexPosition[ 3460, 100] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{"MontyHall", ":=", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "A", " ", "fun\[CCedilla]\[ATilde]o", " ", "retorna", " ", "1", " ", "se", " ", "ganha", " ", "ao", " ", "trocar"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Premio", "=", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "3"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"EscolhaInicial", "=", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "3"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"EscolhaApresentador", "=", "1"}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"Or", "[", RowBox[{ RowBox[{"EscolhaApresentador", "\[Equal]", "Premio"}], ",", RowBox[{"EscolhaApresentador", "\[Equal]", "EscolhaInicial"}]}], "]"}], ",", RowBox[{"EscolhaApresentador", "++"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "2"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Output", "=", RowBox[{"If", "[", RowBox[{ RowBox[{"EscolhaInicial", "\[Equal]", "Premio"}], ",", "0", ",", "1"}], "]"}]}]}], "\[IndentingNewLine]", "}"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.526290680779043*^9, 3.5262908541421475`*^9}, { 3.526290890958212*^9, 3.5262909200678635`*^9}, {3.5262909744027586`*^9, 3.526290975744361*^9}, {3.526726008631978*^9, 3.5267260103160744`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"SimulaMH", "[", "n_", "]"}], ":=", "\[IndentingNewLine]", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"T", "=", RowBox[{"Table", "[", RowBox[{"MontyHall", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Sucesso", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{"T", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"Sucesso", "/", "n"}]}], "]"}]}], "\[IndentingNewLine]", "}"}]}]], "Input", CellChangeTimes->{{3.5262909978028*^9, 3.5262910611389112`*^9}, { 3.5267260824316177`*^9, 3.526726093055237*^9}}] }, WindowSize->{707, 505}, WindowMargins->{{225, Automatic}, {Automatic, 38}}, FrontEndVersion->"8.0 for Microsoft Windows (64-bit) (November 7, 2010)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[557, 20, 1707, 40, 212, "Input"], Cell[2267, 62, 887, 24, 132, "Input"] } ] *) (* End of internal cache information *)