练习1.10

Ackermann数学函数:

(define (A x y)
    (cond ((= y 0) 0)
          ((= x 0) (* 2 y))
          ((= y 1) 2)
          (else (A (- x 1)
                   (A x (- y 1))))))

A(x,y)={0,y=02y,x=0A(x1,A(x,y1)),other cases A(x,y)=\left\{ \begin{array}{ll} 0,&\text{y=0}\\ 2y,&\text{x=0}\\ A(x-1,A(x,y-1)),&\text{other cases} \end{array}\right.

(A 1 10)
; 1024

(A 2 4)
; 65536

(A 3 3)
; 65536

定义如下过程:

(define (f n) (A 0 n))

(define (g n) (A 1 n))

(define (h n) (A 2 n))

易知:

f(n)=2ng(n)=2nh(n)=22..2(n times) \begin{array}{lcl} f(n) = 2n\\ g(n) = 2^{n}\\ h(n) = 2^{2^{.^{.^2}}}\text{(n times)} \end{array}

results matching ""

    No results matching ""