Logarithmic solution of Fibonacci algorithm construction and interpretation of computer program exercise 1.19

Source: Internet
Author: User

The program is written in the scheme language and will be implemented in other languages later.

#lang Racket;Fibonacci Logarithm Method;Filter(define (fib N) (Fib-iter1 0 0 1N)) (define (square x) (* x x)) (define (Fib-iter a b p q count) (Cond (= count 0) b);count = 0 o'clock, fib (1) = 0(even. Count);if it is an even number, then the value of P,q is         ;p = p^2 + q^2         ;q = 2pq + q^2         ;the number of count is halved( Fib-iter a B (+ (square p) (square Q)) (+ (*2p Q)                  (square Q)) (/Count2)))        ;if not, that is odd, then go to the next operation by lowering the power(Else (fib-iter (* b q) (* a Q) (* a P)) (+ (* b q) (* a Q)) p Q (-Count1))))

Logarithmic solution of Fibonacci algorithm construction and interpretation of computer program exercise 1.19

Related Article

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.