Skip to content
This repository was archived by the owner on Sep 7, 2025. It is now read-only.

Commit 93fac7e

Browse files
Cortysabranhe
authored andcommitted
added fibonacci sequence
1 parent 9e1406b commit 93fac7e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

algorithms/math/fibonacci.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(ns math.fibonacci)
2+
3+
(defn fibonacci [n]
4+
(cond
5+
(<= n 0) 0
6+
(<= n 2) 1
7+
:else
8+
(loop [i 2, a 1N, b 1N]
9+
(if (= i n) b
10+
(recur (inc i) b (+ a b))))))

0 commit comments

Comments
 (0)