September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,6 +1,11 @@
|
|||
(defn fib [n]
|
||||
(case n
|
||||
0 0
|
||||
1 1
|
||||
(+ (fib (- n 1))
|
||||
(fib (- n 2)))))
|
||||
(letfn [(fib* [n]
|
||||
(if (zero? n)
|
||||
[0 1]
|
||||
(let [[a b] (fib* (quot n 2))
|
||||
c (*' a (-' (*' 2 b) a))
|
||||
d (+' (*' b b) (*' a a))]
|
||||
(if (even? n)
|
||||
[c d]
|
||||
[d (+' c d)]))))]
|
||||
(first (fib* n))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue