Roll a 6-sided die until you have rolled a total of 25 6's.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Colton Baker
am 11 Sep. 2020
Kommentiert: Walter Roberson
am 12 Sep. 2020
Hello,
I am trying to wrtie a script to roll randi(6) and loop until it has reached 25 sixes and then count how many rolls it took. Help please.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Asad (Mehrzad) Khoddam
am 11 Sep. 2020
find(cumsum(randi(6,1,1000)==6)==25,1)
3 Kommentare
Asad (Mehrzad) Khoddam
am 11 Sep. 2020
Bearbeitet: Asad (Mehrzad) Khoddam
am 11 Sep. 2020
Yes, you are right. Simply if it happens, you can try again
The probability is 1.536e-48 (it happens once in 6.5e47 tries)
Walter Roberson
am 12 Sep. 2020
You wouldn't quite just try again... you would have to subtract off the number of 6's that you got up to that point, and you would have to add the number of attempts you already made to the index.
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!