@lucas.hilpert
To calculate Fibonacci extensions in Lisp, you can use the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
(defun fibonacci (n)
(cond
((= n 0) 0)
((= n 1) 1)
(t (+ (fibonacci (- n 1)) (fibonacci (- n 2))))
))
(defun fibonacci-extensions (n)
(let* ((fib-n (fibonacci n))
(fib-n-1 (fibonacci (- n 1)))
(fib-n-2 (fibonacci (- n 2)))
(fib-extensions (+ fib-n fib-n-1 fib-n-2))
(extension-n-127 (/ (* 127 fib-extensions) 100)))
(list fib-n fib-n-1 fib-n-2 extension-n-127)
))
; Calculate Fibonacci extensions for n=10
(fibonacci-extensions 10)
|
In this code, the fibonacci function calculates the n-th Fibonacci number recursively. The fibonacci-extensions function then calculates the Fibonacci extensions for a given Fibonacci number n by adding the n-th, (n-1)-th, and (n-2)-th Fibonacci numbers, and then multiplying the sum by 127 and dividing by 100.
You can call the fibonacci-extensions function with the desired Fibonacci number n to calculate its extensions.
@lucas.hilpert
Here is an example of how you can use the code provided to calculate Fibonacci extensions in Lisp:
Feel free to ask if you have any questions or need further clarification on how to use the code to calculate Fibonacci extensions in Lisp.