hktony

Untitled

Sep 24th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. (define (tree-count-min n) (cond
  2. [(<= n 1) n]
  3. [true (/ (/ (factorial (tree-count-min-helper n 1)) (factorial (+ (- n (tree-count-min-helper n 1)) 1))) (factorial (- (- (* 2 (tree-count-min-helper n 1)) n) 1)))]))
  4.  
  5. (define (tree-count-min-helper n m) (if (<= m n) (tree-count-min-helper n (* m 2)) (/ m 2)))
  6.  
  7. (define (factorial n) (cond
  8. [(<= n 1) n]
  9. [true (* n (factorial (- n 1)))]))
Advertisement
Add Comment
Please, Sign In to add comment