Advertisement
Guest User

Untitled

a guest
Jan 30th, 2021
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function random_seed(seed, max = 2) {
  2.     var x = Math.abs(Math.round(Math.sin(seed) * max));
  3.     return x;
  4. }
  5. no_ones = 0
  6. no_zeros = 0
  7. function range(start, stop, step=1) {
  8.     var a = [start], b = start;
  9.     while (b < stop) {
  10.         a.push(b += step || 1);
  11.     }
  12.     return a;
  13. }
  14.  
  15. range(0,10000000).forEach((r,i) => {
  16.   if(random_seed(Math.random()) == 0) {
  17.   no_zeros++
  18.   } else if(random_seed(Math.random()) == 1) {
  19.   no_ones++
  20.   }
  21. })
  22.  
  23. console.log(`ratio: ${no_zeros/no_ones}`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement