"SICP Exercise" 7 Exercise 1.20

Source: Internet
Author: User

Exercise 1.20

This problem requires us to study the GCD function in the book in the context of both the regular order and the application sequence, and also to figure out the number of actual remainder operations performed.

The first question in the question is the application sequence, but since the application sequence is relatively simple, let's take a look at the application sequence:

(GCD 206 40)

(GCD 40 6)

(GCD 6 4)

(GCD 4 2)

(GCD 2 0)

2

Therefore (GCD 206 40) A total of 5 remainder functions were called.

Take a look at the case of the regular sequence:

(GCD 206 40)

(GCD (remainder 206 40))

(gcd (remainder 206) (Remainder (remainder (206 40)))

(GCD (Remainder (remainder (206))) (Remainder (remainder 206) (Remainder (remainder (206 40))))

(GCD (remainder (remainder 206) (Remainder (remainder (206 40)))) (Remainder (remainder (remainder (206))) (Remainder (remainder 206) (Remainder (remainder (206 40)))))

This is equivalent to the parameter is 2 and 0, where I have been removed, as to how many times the number of remainder calls to know.

"SICP Exercise" 7 Exercise 1.20

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.