15 lines
267 B
Scheme
15 lines
267 B
Scheme
(define (range a b)
|
|
(if (> a b) '() (cons a (range (add1 a) b))))
|
|
|
|
(define (sum lst)
|
|
(foldl + 0 lst))
|
|
|
|
(define (sqr a)
|
|
(* a a))
|
|
|
|
(define (problem6 v)
|
|
(let ((r (range 1 v)))
|
|
(- (sqr (sum r)) (sum (map sqr r)))))
|
|
|
|
(print (problem6 10))
|
|
(print (problem6 100))
|