Fermat's Wager
Jump to navigation
Jump to search
Showing my working for this proposal. --Kevan (talk) 16:48, 11 August 2020 (UTC)
Contents
Code
$wins = array(0,0,0,0,0,0,0); for ($i=0; $i<1000000; $i++) { $scores = array(2,2,1,0,0,0,0); while (max($scores)<3) { $scores[rand(0,6)]++; } $wins[array_search(max($scores),$scores)]++; } print_r($wins);
Output
Array ( [0] => 408544 [1] => 409071 [2] => 93189 [3] => 22226 [4] => 22446 [5] => 22190 [6] => 22334 )
Exact
Completely unnecessary in light of the above; we don't need the extra accuracy, but I was curious: Pokes (talk) 19:05, 11 August 2020 (UTC)
#include <stdio.h> int base_plaques[7] = {2, 2, 1, 0, 0, 0, 0}; int current_plaques[7]; int wins[7]; int main() { int outcomes = 7*7*7*7*7*7*7*7*7*7; int i, j, t; int round; int winner; for (j = 0; j < 7; j++) wins[j] = 0; for (i = 0; i < outcomes; i++) { t = i; for (j = 0; j < 7; j++) current_plaques[j] = base_plaques[j]; for (round = 0; round < 10; round++) { winner = t % 7; t /= 7; current_plaques[winner]++; if (current_plaques[winner] == 3) { wins[winner]++; break; } } } for (j = 0; j < 7; j++) { printf("%15d %f\n", wins[j], 100.0*((float)(wins[j])/(float)(outcomes))); } }
Output
115528224 40.898529 115528224 40.898529 26375517 9.337284 6260821 2.216414 6260821 2.216414 6260821 2.216414 6260821 2.216414