(42S) Subfactorial
|
09-06-2021, 06:50 PM
(This post was last modified: 09-06-2021 06:55 PM by John Keith.)
Post: #2
|
|||
|
|||
RE: (42S) Subfactorial
A simpler formula for the first program is a(n) = (n-1)*(a(n-1) + a(n-2)). Maybe not as easy to implement with a 4-level stack because you have to keep the two previous values to compute the current one.
The second formula can also be simplified to round(n!/e). More information and formulas at A000166. On Free42 or the DM42 you have over 30 digits of precision so your first program (either formula) will be exact for fairly large values of n. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)