Uname : Linux premium36.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Soft : LiteSpeed
Ip : 198.54.115.237
Port : 443
~
/
lib
/
node_modules
/
npm
/
node_modules
/
worker-farm
/
examples
/
pi
[ HOME ]
Exec
Submit
calc.js
'use strict' /* A simple π estimation function using a Monte Carlo method * For 0 to `points`, take 2 random numbers < 1, square and add them to * find the area under that point in a 1x1 square. If that area is <= 1 * then it's *within* a quarter-circle, otherwise it's outside. * Take the number of points <= 1 and multiply it by 4 and you have an * estimate! * Do this across multiple processes and average the results to * increase accuracy. */ module.exports = function (points, callback) { let inside = 0 , i = points while (i--) if (Math.pow(Math.random(), 2) + Math.pow(Math.random(), 2) <= 1) inside++ callback(null, (inside / points) * 4) }
Submit
Back
Folder Name
Submit
File Name
File Content
Submit
Name
Type
Size
Permission
Last Modified
Actions
.
dir
-
0755
2024-03-03 10:36:29
..
dir
-
0755
2024-03-03 10:36:29
calc.js
text/plain
683 B
0644
2021-03-10 02:36:36
index.js
text/plain
1.18 KB
0644
2021-03-10 02:36:36