Jump to content

Primality by trial division: Difference between revisions

(Added an ActionScript version.)
(→‎{{header|Scheme}}: Simplified.)
Line 626:
 
=={{header|Scheme}}==
{{Works with|Scheme|R<math>^5</math>RS}}
<lang scheme>(define (is-prime? xnumber)
(cond ((< x 2) #f)
(define ((= x 2)*prime? #tdivisor)
(or ((zero?> (remainder* xdivisor 2)divisor) #fnumber)
(elseand (> (modulo number divisor) 0)
(let loop (*prime? (c+ divisor 31)))))
(condand ((> (* c c) x)number #t1)
((zero*prime? (remainder x c2)) #f)</lang>
(else (loop (+ c 2))))))))</lang>
 
=={{header|Standard ML}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.