fork(3) download
  1. ; counting primes
  2.  
  3. (define (prime-pi n)
  4. (if (< n 2) 0 (if (< n 3) 1 (if (< n 4) 2
  5. (let loop ((j 3) (j2fact 1) (pi -1))
  6. (if (< n j) pi
  7. (let ((j2fact (* j2fact (- j 2))))
  8. (loop (+ j 1) j2fact (+ pi (- j2fact
  9. (* j (quotient j2fact j))))))))))))
  10.  
  11. (display (prime-pi 1000)) (newline)
Success #stdin #stdout 0.08s 9960KB
stdin
Standard input is empty
stdout
168