You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
363 B

;; 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)
)
)
)