The revolutionary project management tool is here! Plan visually with a single glance and make sure your projects get done.
(define (fact n) ;;method to solve a factorial
(if (= n 0)
1
(* n (fact (- n 1)))))
(define count 0) ;;keeps track of progress
(define total 0) ;;keeps running total
(define (e limit)
(if (< count limit)
total
(e (+ total (/ 1 (fact (+ count 1)))))
)
)
(define (fact n) ;;method to solve a factorial
(if (= n 0)
1
(* n (fact (- n 1)))))
(define (term x) ;;method to solve a single term
(/ 1 (fact x)))
(define count -1) ;;counter variable
(define total 0) ;;variable to hold ongoing total
(define (e limit)
(if (= count limit) ;;when the limit reaches count, it outputs total
total
(+ total (term limit) (e (- limit 1))) ;;adds to the total the current term and recursively calls the next number. Counts down to -1 (so that we include 0 in our calc)
)
)