e=1/0!+1/1!+1/2!+1/3!……
I wrote the code like that, but whatever I input, it just returns 2….
Could you help me with that?
(define (fact n)
(if (= n 0)
1
(* n (- n 1))))
(define (e limit)
(if (= limit 0)
1
(+ (/ 1 (fact limit)) (e (- limit 1)))))
There’s a mistake in the
factprocedure:Test each procedure throughly, a simple unit test would have revealed that the problem was in
factand not in theeprocedure.