clear; clc;

rng(100);

M = 1e4;
m = 0;
for i = 1 : M
    s = 0;
    while s < 1
        s = s + rand(1);
        m = m + 1;
    end
end
m / M