Benford's law: Difference between revisions

added Arturo
(Added XPL0 example.)
(added Arturo)
Line 399:
Benford: 0.046 actual: 0.045
</pre>
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">fib: [a b]: <= [0 1]
do.times:998 -> [a b]: @[b 'fib ++ <= a+b]
 
leading: fib | map 'x -> first ~"|x|"
| tally
 
print "digit actual expected"
loop 1..9 'd ->
print [
pad.right ~"|d|" 8
pad.right ~"|leading\[d] // 1000|" 9
log 1 + 1//d 10</syntaxhighlight>
 
{{out}}
 
<pre>digit actual expected
1 0.301 0.3010299956639811
2 0.177 0.1760912590556812
3 0.125 0.1249387366082999
4 0.095 0.09691001300805641
5 0.08 0.0791812460476248
6 0.067 0.06694678963061322
7 0.056 0.05799194697768673
8 0.053 0.05115252244738128
9 0.045 0.04575749056067514</pre>
 
=={{header|AutoHotkey}}==
{{works with|AutoHotkey_L}}(AutoHotkey1.1+)
Line 455 ⟶ 483:
8 5.115252 5.300000 0.184748
9 4.575749 4.500000 0.075749</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
1,532

edits