summaryrefslogtreecommitdiff
path: root/euler114.scm
blob: e23b44115db1ea97756d9d58fed1a6f835f1f8cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(define (comb m n)
  (define (citer mm nn prod)
    (if (> mm m) prod
        (citer (+ mm 1) (- nn 1) (/ (* prod nn) mm))))
  (citer 1 n 1))

(define (solve nn)
  (define (addto m n)
    (if (> m n) 0
        (+ (comb m n) (addto (+ m 2) (- n 2)))))
  (+ 1 (addto 2 (- nn 1))))

(display (solve 50))
(newline)