@jajoosam/

tweetcode

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const count = 10000;
const radius = 10000;
const rand = () => Math.floor(Math.random() * (radius*2)) + 1;

let inside = 0;

for(z = 0; z<count; z++){
  let x = rand()
  let y = rand(); 
  if(Math.sqrt(Math.abs((Math.pow(radius-x, 2))+(Math.pow(radius-y, 2))))<=radius){
    inside+=1;
  }
}

console.log((inside/count)*4)

node v10.16.0