Skip to content

Instantly share code, notes, and snippets.

@kirillsulim
Created December 10, 2018 18:35
Show Gist options
  • Save kirillsulim/68d98f6cbcc5287159880566c0189d09 to your computer and use it in GitHub Desktop.
Save kirillsulim/68d98f6cbcc5287159880566c0189d09 to your computer and use it in GitHub Desktop.
Random step problem
l = (N) => {
sum = 0, iter = 1000000;
for (let i = 1; i < iter; i++) {
var s = 0,
j = 0;
while (s < N) {
s += Math.random();
j++;
}
sum += j;
}
console.log(sum / iter)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment