Jump to content

Sleeping Beauty problem: Difference between revisions

Add Factor
mNo edit summary
(Add Factor)
Line 31:
 
 
 
=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
<lang factor>USING: combinators.random io kernel math prettyprint ;
 
: sleeping ( n -- heads wakenings )
0 0 rot [ 1 + .5 [ [ 1 + ] dip ] [ 1 + ] ifp ] times ;
 
"Wakenings over 1,000,000 experiments: " write
1e6 sleeping dup . /f
"Sleeping Beauty should estimate a credence of: " write .</lang>
{{out}}
<pre>
Wakenings over 1,000,000 experiments: 1500127
Sleeping Beauty should estimate a credence of: 0.3332204540015612
</pre>
 
=={{header|Julia}}==
1,827

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.