Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions