Question: I'm using Scheme on DrRacket. This is my prime function: (define prime-test-iterations 20) (define prime? (lambda (p) (define a (big-random p)) (cond ((= prime-test-iterations 0)
I'm using Scheme on DrRacket.
This is my prime function:
(define prime-test-iterations 20)
(define prime?
(lambda (p)
(define a (big-random p))
(cond ((= prime-test-iterations 0) #t)
((not (= (exptmod a p p) a)) #f)
(else (- prime-test-iterations 1) (prime? p)))
.(big-random n) gives a random number smaller than n.
.(exptmod a b c) finds a to the power b modulo c (a^b = ? (mod c))
My prime function can't even calculate if 2 is prime.
What's wrong with it?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
