primes/primes.scm

27 lines
363 B
Scheme

;; Scheme version of a Prime Number Finder
;; haplo@mindstab.net
(define (check cnt i MAX)
(if (> i MAX)
1
(if (= (modulo cnt i) 0)
0
(check cnt (+ i 2) MAX)
)
)
)
(define (primes cnt MAX)
(if (<= cnt MAX)
(and
(if (not (= (check cnt 3 (sqrt cnt)) 0))
(and (display cnt) (display "\n"))
)
(primes (+ cnt 2) MAX)
)
)
)