fork download
  1. ; estimating pi
  2.  
  3. (define (rand50) (inexact->exact (random #e1e50)))
  4.  
  5. (define (pi n)
  6. (let loop ((m n) (k 0))
  7. (if (zero? m) (sqrt (* 6 n (/ k)))
  8. (let ((a (rand50)) (b (rand50)))
  9. (loop (- m 1) (if (= 1 (gcd a b)) (+ k 1) k))))))
  10.  
  11. (display (pi 100000)) (newline)
Success #stdin #stdout 1.93s 9212KB
stdin
Standard input is empty
stdout
3.1407328456921855