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.
Fibonacci
Fibonacci
Sort by
recency
|
33 Discussions
|
Please Login in order to post a comment
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)))) )
had to write it in a REPL
f# my first attempt hand with made cache no modulo property used: (a + b) % n = ((a % n) + (b % n)) % n.
memoized_fib :: Int -> Integer memoized_fib = (map fib [0 ..] !!) where fib 0 = 0 fib 1 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1)
mymod :: Integer -> Integer mymod x = mod x ((10^8) + 7)
atoi :: String -> Int atoi = read
main = interact $ unlines . map (show. mymod) . map memoized_fib . map atoi . tail .lines
This help me a lot in making multiple bills functions. duplicatebills.com lesco bill online check(wapda bill online check) page. If you are a Citizen of the internationally famous city its surrounding cities then you are on the right website. Here you will find an easy method to check your lesco bill online and lots of useful information and latest news related to lesco.