Untitled

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> int main() { srand48(time(NULL) ^ getpid()); for (double i = 0.0; i <= 1.0001; i += 0.05) { unsigned c[2] = { 0, 0 }; for (unsigned j = 0; j < 10000000; ++j) { for (double x = i;;) { double d = x < 0.5 ? x : 1.0 - x; x = drand48() < 0.5 ? x - d : x + d; if (x <= 0.0 || x >= 1.0) { c[x <= 0.0 ? 0 : 1]++; break; } } } printf("x=%.3f p=%.4f\n", i, (double)c[1] / (double)(c[0] + c[1])); } }
Editor Settings
Theme
Key bindings
Full width
Lines