(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)
)
)
Title | # Comments | Views | Activity |
---|---|---|---|
Need Help,, i m beginner in vba,, i'm writing a code for exporting the data from Userform to Access Database | 13 | 96 | |
VB 6.0 printer how to align | 6 | 49 | |
countPairs challenge | 7 | 58 | |
Installed softare without GUID | 6 | 55 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
12 Experts available now in Live!