Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM sum = 1/1! + 2/2! + 3/3! + 4/4! + ... + n/n! : n = 10 ' mathemtically we can reduce it to :
- REM sum = 1/0! + 1/1! + 1/2! + 1/3! + ... + 1/(n-1)! [calculate this]
- ''''''''''''''''''''''''''''''''''''''''''''''''
- let sum = 0
- let factorial = 1
- for n = 0 to 100
- if n = 0 then factorial = 1
- if n > 0 then factorial = factorial * (n)
- sum = sum + 1/factorial
- next n
- ''''''''''''''''''''''''''''''''''''''''
- print sum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement