Last active
May 17, 2023 00:43
-
-
Save chase-lambert/b45315698a31c0129165c952caa06563 to your computer and use it in GitHub Desktop.
rendezvous with cassidoo challenge: 22.10.02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that this isn't just "fib like", this will actually give you the fibonacci sequence if
a
andb
are both 1.