Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Last active December 17, 2015 20:49
Show Gist options
  • Save aoeuidht/5670288 to your computer and use it in GitHub Desktop.
Save aoeuidht/5670288 to your computer and use it in GitHub Desktop.
exericse 1.11
(defun calc-f (n)
(if (< n 3)
n
(+ (calc-f (- n 1))
(* (calc-f (- n 2)) 2)
(* (calc-f (- n 3)) 3)
))
)
(defun calc-f (n)
(calc-f-iter 2 1 0 n)
)
(defun calc-f-iter (a b c count)
(if (= count 0)
c
(calc-f-iter (+ a (* b 2) (* c 3))
a
b
(- count 1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment