Question: **Language is SCHEME (R5RS)** 2. A integer n> 1 is prime if its only positive divisors are 1 and n. (The convention is not to

**Language is SCHEME (R5RS)**

**Language is SCHEME (R5RS)** 2. A integer n> 1 is prime if

2. A integer n> 1 is prime if its only positive divisors are 1 and n. (The convention is not to call 1 prime.) The following scheme procedure determines if a number is prime. (define (prime? n) (define (divisor? k) (0 (modulo n k))) (define (divisors-upto k.) (and ( k 1) (not (divisors-upto (- n 1)))) (So, it returns #t for prime numbers like 2, 3, 5, 7, and 11 and #f for composite (that is, non-prime) numbers like 4, 6, 8, and 9.) Using this procedure, write a function count-primes so that (count-primes t) returns the number of prime numbers between 1 and t

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!