; counting primes
(define (prime-pi n)
(if (< n 2) 0 (if (< n 3) 1 (if (< n 4) 2
(let loop ((j 3) (j2fact 1) (pi -1))
(if (< n j) pi
(let ((j2fact (* j2fact (- j 2))))
(loop (+ j 1) j2fact (+ pi (- j2fact
(* j (quotient j2fact j))))))))))))
(display (prime-pi 1000)) (newline)
OyBjb3VudGluZyBwcmltZXMKCihkZWZpbmUgKHByaW1lLXBpIG4pCiAgKGlmICg8IG4gMikgMCAoaWYgKDwgbiAzKSAxIChpZiAoPCBuIDQpIDIKICAgIChsZXQgbG9vcCAoKGogMykgKGoyZmFjdCAxKSAocGkgLTEpKQogICAgICAoaWYgKDwgbiBqKSBwaQogICAgICAgIChsZXQgKChqMmZhY3QgKCogajJmYWN0ICgtIGogMikpKSkKICAgICAgICAgIChsb29wICgrIGogMSkgajJmYWN0ICgrIHBpICgtIGoyZmFjdAogICAgICAgICAgICAgICAgKCogaiAocXVvdGllbnQgajJmYWN0IGopKSkpKSkpKSkpKSkKCihkaXNwbGF5IChwcmltZS1waSAxMDAwKSkgKG5ld2xpbmUp