summaryrefslogtreecommitdiff
path: root/euler20.scm
blob: df06c9d384990b8e38935620aeb8359fb5e1e5a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(define (sum-digits n)
 (if (= n 0)
  0
  (+ (remainder n 10)
   (sum-digits (floor (/ n 10))))))

(define (! n)
 (define (p-iter i p)
  (if (> i n)
   p
   (p-iter (+ i 1) (* p i))))
 (p-iter 1 1))

(display (sum-digits (! 100)))
(newline)