[ $ "bigrat.qky" loadfile ] now! [ tuck space swap of join swap split drop echo$ ] is lecho$ ( $ n --> ) [ 1 swap times [ i 1+ * ] ] is ! ( n --> n ) [ 0 n->v rot dup temp put times [ temp share ! n->v temp share i 1+ - ! n->v v/ temp share i 1+ ** n->v v/ v+ ] temp release ] is expected ( n --> n/d ) [ -1 temp put 0 [ 1 temp tally over random bit 2dup & not while | again ] 2drop drop temp take ] is trial ( n --> n ) [ tuck 0 swap times [ over trial + ] nip swap reduce ] is trials ( n n --> n/d ) [ say " n average expected difference" cr say "-- ------- -------- ----------" cr 20 times [ i^ 1+ dup 10 < if sp echo 2 times sp i^ 1+ 1000000 trials 2dup 7 point$ 10 lecho$ i^ 1+ expected 2dup 7 point$ 11 lecho$ v/ 1 n->v v- 100 1 v* vabs 7 point$ echo$ say "%" cr ] ] is task ( --> )