fibs扩展2

    技术2022-05-19  24

    //right-hand has  a  constant 10 with fibs function(defun  fibs (n)(if (eq  n 1)       2    (if (eq n 2)           3       (+ 10          (- (* 6  (fibs (- n 1) ) )          (* 8  (fibs (- n 2) ) ))))))GOf(t+2)-6*f(t+1)+8*f(t)=10f(t+3)-6*f(t+2)+8*f(t+1)=10GO  ( below minus above)f(t+3)-7*f(t+2)+14*f(t+1)-8*f(t)=0GO(X-2)(X-1)(X-4)=0GO2*A+4*B+C=24*A+16*B+C=38*A+64*B+C=12GOA=-5/4B=7/24C=10/3

    (defun pow (num count)(if (> count 0)      (* num (pow num (- count 1) ) )    1))

    (setq  A  (- 0 (/ 5 4.0) ))(setq  B  (/ 7  24.0))(setq  C  (/ 10  3.0))

    (defun  formula (n)(+  (* A  (pow 2 n))    (* B  (pow 4 n))    C ))

    (defun  test (n)(if (> n 0)  (progn        (print (formula n))       (print (fibs n))       (test  (- n 1) ))  (print 'over)))

    (test  10)


    最新回复(0)