We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Never posted one of these so sorry if the formatting isn't right but I didn't see a clojure solution yet so here is mine below.(def my_func
(memoize (fn [n]
(condp = n
0 0
1 1
2 1
(mod (+ (my_func (dec n)) (my_func (- n 2))) 100000007)))))
(def a (Integer/parseInt (read-line)))
(doseq [a-itr (range a)]
(println (my_func (Integer/parseInt (read-line))))
)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci
You are viewing a single comment's thread. Return to all comments →
Never posted one of these so sorry if the formatting isn't right but I didn't see a clojure solution yet so here is mine below.
(def my_func (memoize (fn [n] (condp = n 0 0 1 1 2 1 (mod (+ (my_func (dec n)) (my_func (- n 2))) 100000007))))) (def a (Integer/parseInt (read-line))) (doseq [a-itr (range a)] (println (my_func (Integer/parseInt (read-line)))) )