Uname : Linux premium36.web-hosting.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64
Soft : LiteSpeed
Ip : 198.54.115.237
Port : 443
~
/
opt
/
alt
/
alt-nodejs10
/
root
/
lib
/
node_modules
/
npm
/
node_modules.bundled
/
worker-farm
/
examples
/
pi
[ HOME ]
Exec
Submit
File Name : 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) }
Back
Folder Name
Submit
File Name
File Content
Submit
Name
Type
Size
Permission
Last Modified
Actions
.
dir
-
0755
2024-03-03 10:41:29
..
dir
-
0755
2024-03-03 10:41:29
calc.js
text/plain
683 B
0644
2023-03-22 10:59:01
index.js
text/plain
1.18 KB
0644
2023-03-22 10:59:01