Skip to content

Instantly share code, notes, and snippets.

@chase-lambert
Last active May 17, 2023 00:43
Show Gist options
  • Save chase-lambert/b45315698a31c0129165c952caa06563 to your computer and use it in GitHub Desktop.
Save chase-lambert/b45315698a31c0129165c952caa06563 to your computer and use it in GitHub Desktop.
rendezvous with cassidoo challenge: 22.10.02
(ns fib-like
(:require [clojure.test :refer [deftest is]]))
(defn fibber [a b]
(lazy-seq
(cons a (fibber b (+ a b)))))
(defn fib-like [a b n]
(take n
(fibber a b)))
(deftest fib-like-test
(let [n 5]
(is (= [10 20 30 50 80] (fib-like 10 20 n)))
(is (= [ 3 7 10 17 27] (fib-like 3 7 n)))))
@chase-lambert
Copy link
Author

Note that this isn't just "fib like", this will actually give you the fibonacci sequence if a and b are both 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment