Monte Carlo methods: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(Added solution for EDSAC) |
m (→{{header|Wren}}: Minor tidy) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1,022:
=={{header|EasyLang}}==
<syntaxhighlight lang="text">
func mc n .
for
.
.
.
numfmt 4 0
</syntaxhighlight>
Output:
3.1292
Line 1,731 ⟶ 1,733:
piMC 10^i.7
4 2.8 3.24 3.168 3.1432 3.14256 3.14014</syntaxhighlight>
'''Alternative Tacit Solution:'''
<syntaxhighlight lang="j">pimct=. (4 * +/ % #)@:(1 >: |)@:(? j. ?)@:($&0)"0
(,. pimct) 10 ^ 3 + i.6
1000 3.168
10000 3.122
100000 3.13596
1e6 3.1428
1e7 3.14158
1e8 3.14154</syntaxhighlight>
=={{header|Java}}==
Line 2,819 ⟶ 2,832:
=={{header|RPL}}==
≪ 0
RAND SQ RAND SQ + 1 < +
SWAP / 4 * ▼
▲ SWAP / 4 *
≫ '<span style="color:blue">MCARL</span>' STO
100
1000 <span style="color:blue">MCARL</span>
10000
100000 <span style="color:blue">MCARL</span>
{{out}}
<pre>
4: 3.
3: 3.
2: 3.
1: 3.
</pre>
Line 3,204 ⟶ 3,219:
{{trans|Kotlin}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="
import "./fmt" for Fmt
var rand = Random.new()
|