Anonymous user
Monte Carlo methods: Difference between revisions
→{{header|Crystal}}
No edit summary |
|||
Line 423:
=={{header|Crystal}}==
{{trans|Ruby}}
<lang ruby>def approx_pi(throws)
times_inside = throws.times.count {Math.hypot(rand, rand) <= 1.0}
|