Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function random_seed(seed, max = 2) {
- var x = Math.abs(Math.round(Math.sin(seed) * max));
- return x;
- }
- no_ones = 0
- no_zeros = 0
- function range(start, stop, step=1) {
- var a = [start], b = start;
- while (b < stop) {
- a.push(b += step || 1);
- }
- return a;
- }
- range(0,10000000).forEach((r,i) => {
- if(random_seed(Math.random()) == 0) {
- no_zeros++
- } else if(random_seed(Math.random()) == 1) {
- no_ones++
- }
- })
- console.log(`ratio: ${no_zeros/no_ones}`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement