Advertisement
4da

compute summ of combinations

4da
Nov 30th, 2011
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.22 KB | None | 0 0
  1. (define fac
  2.   0 -> 1
  3.   N -> (* N (fac (- N 1))))
  4.  
  5. (define combination
  6.   N K -> (/ (fac N) (* (fac (- N K)) (fac K))))
  7.  
  8. (define sum-to-n
  9.   N 0 -> (combination N 0)
  10.   N K -> (+ (combination N K) (sum-to-n N (- K 1))))
  11.  
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement