We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 471fd95 commit 045fb52Copy full SHA for 045fb52
contents/monte_carlo_integration/code/javascript/monte_carlo.js
@@ -23,7 +23,7 @@ function monteCarlo(n) {
23
// 4*piCount/n instead
24
// piEstimate = 4*piCount/n
25
const piEstimate = 4 * piCount / n;
26
- console.log('Percent error is: %s%', 100 * (Math.PI - piEstimate) / Math.PI);
+ console.log('Percent error is: %s%', 100 * Math.abs(piEstimate - Math.PI) / Math.PI);
27
}
28
29
monteCarlo(100000000);
0 commit comments