Skip to content

Instantly share code, notes, and snippets.

@Edmundworks
Created May 29, 2018 14:06
Show Gist options
  • Save Edmundworks/ffa23239529d2d8bc8773c6b5b80f235 to your computer and use it in GitHub Desktop.
Save Edmundworks/ffa23239529d2d8bc8773c6b5b80f235 to your computer and use it in GitHub Desktop.
SICP 1.11 A function f is defined by the rule that f(n)=n if n<3 and f(n)=f(n−1)+2f(n−2)+3f(n−3) if n>3. Write a procedure that computes f by means of a recursive process.
(define (f n)
(cond ((< n 3) n)
else (+
(f (- n 1)
(* 2 (f (- n 2)))
(* 3 (f (- n 3)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment