Monte Carlo methods: Difference between revisions

Content added Content deleted
(Add Jsish)
Line 1,354: Line 1,354:


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia>using Printf
{{works with|Julia|0.6}}


<lang julia>function monteπ(n)
function monteπ(n)
s = count(rand() ^ 2 + rand() ^ 2 < 1 for _ in 1:n)
s = count(rand() ^ 2 + rand() ^ 2 < 1 for _ in 1:n)
return 4s / n
return 4s / n