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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!