Monte Carlo methods: Difference between revisions

Content added Content deleted
No edit summary
Line 423: Line 423:


=={{header|Crystal}}==
=={{header|Crystal}}==
{{trans|Ruby}}
<lang ruby>def approx_pi(throws)
<lang ruby>def approx_pi(throws)
times_inside = throws.times.count {Math.hypot(rand, rand) <= 1.0}
times_inside = throws.times.count {Math.hypot(rand, rand) <= 1.0}