Post Reply 
(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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(42S) Subfactorial - Eddie W. Shore - 09-06-2021, 04:43 PM
RE: (42S) Subfactorial - John Keith - 09-06-2021 06:50 PM
RE: (42S) Subfactorial - Albert Chan - 09-07-2021, 02:21 PM
RE: (42S) Subfactorial - Werner - 09-09-2021, 07:24 AM
RE: (42S) Subfactorial - Albert Chan - 09-09-2021, 03:33 PM
RE: (42S) Subfactorial - Albert Chan - 09-08-2021, 10:26 PM
RE: (42S) Subfactorial on HP-15C - C.Ret - 09-11-2021, 04:15 PM
RE: (42S) Subfactorial - Werner - 09-09-2021, 07:45 AM
RE: (42S) Subfactorial - Werner - 09-09-2021, 12:31 PM
RE: (42S) Subfactorial - ijabbott - 09-11-2021, 08:24 AM
RE: (42S) Subfactorial - Gil - 09-12-2021, 12:05 AM
RE: (42S) Subfactorial - Albert Chan - 09-12-2021, 12:46 PM



User(s) browsing this thread: 1 Guest(s)