Add Fibonnacci
This commit is contained in:
parent
59cfd6db25
commit
cadd0f02fd
1 changed files with 15 additions and 0 deletions
15
fibonacci-goldener-schnitt.rkt
Normal file
15
fibonacci-goldener-schnitt.rkt
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
;; The first three lines of this file were inserted by DrRacket. They record metadata
|
||||||
|
;; about the language level of this file in a form that our tools can easily process.
|
||||||
|
#reader(lib "htdp-advanced-reader.ss" "lang")((modname fibonacci-goldener-schnitt) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f () #f)))
|
||||||
|
(define (fib n) (cond
|
||||||
|
[(= n 0) 1]
|
||||||
|
[(= n 1) 1]
|
||||||
|
[else (+ (fib (- n 1)) (fib (- n 2)))]
|
||||||
|
))
|
||||||
|
|
||||||
|
(define (make-numbers n) (cond
|
||||||
|
[(= n 0) (list 0)]
|
||||||
|
[else (append (make-numbers (- n 1)) (list n))]
|
||||||
|
))
|
||||||
|
|
||||||
|
(define (x n) (map (lambda (x) (/ (fib (+ x 1)) (fib x))) (make-numbers n)))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue