Post Reply 
HP 50g Double factorial
01-27-2024, 01:50 PM
Post: #20
RE: HP 50g Double factorial
(01-27-2024 05:57 AM)FLISZT Wrote:  ...(from ListExt library).

If you've got ListExt installed, there's a fairly simple way to do this if we are only interested in non-negative integers (ie. no gamma function required):
Code:
\<<
  { 2 - } { 1 > } LWHL
  LPROD
\>>

The first line simply builds the list of multiplicands, given n as the argument on stack level 1:
0 yields { }
1 yields { }
2 yields { 2 }
3 yields { 3 }
4 yields { 4 2 }
5 yields { 5 3 }
6 yields { 6 4 2 }
7 yields { 7 5 3 }
...

By definition, LPROD provides 1 as the result when given an empty list. That works nicely here. Also, using "1 >" as the check condition, the superfluous final "1" is skipped for multiplication with odd n.

Note that this is just the core of the function; if input validation is needed, that should be added as required.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP 50g Double factorial - joeres - 05-01-2019, 11:19 AM
RE: HP 50g Double factorial - Gilles - 05-01-2019, 01:40 PM
RE: HP 50g Double factorial - joeres - 05-01-2019, 03:57 PM
RE: HP 50g Double factorial - Gilles - 05-01-2019, 04:14 PM
RE: HP 50g Double factorial - joeres - 05-01-2019, 06:01 PM
RE: HP 50g Double factorial - John Keith - 05-01-2019, 07:00 PM
RE: HP 50g Double factorial - joeres - 05-02-2019, 08:33 PM
RE: HP 50g Double factorial - grsbanks - 05-01-2019, 04:59 PM
RE: HP 50g Double factorial - Gilles - 05-01-2019, 07:06 PM
RE: HP 50g Double factorial - Albert Chan - 05-01-2019, 06:17 PM
RE: HP 50g Double factorial - joeres - 05-01-2019, 06:26 PM
RE: HP 50g Double factorial - joeres - 05-02-2019, 09:34 PM
RE: HP 50g Double factorial - joeres - 05-01-2019, 06:35 PM
RE: HP 50g Double factorial - FLISZT - 01-27-2024, 05:57 AM
RE: HP 50g Double factorial - DavidM - 01-27-2024 01:50 PM
RE: HP 50g Double factorial - FLISZT - 01-27-2024, 05:51 PM
RE: HP 50g Double factorial - DavidM - 01-27-2024, 09:33 PM
RE: HP 50g Double factorial - FLISZT - 01-28-2024, 01:47 AM
RE: HP 50g Double factorial - DavidM - 01-28-2024, 02:51 PM
RE: HP 50g Double factorial - FLISZT - 01-28-2024, 07:07 PM
RE: HP 50g Double factorial - John Keith - 01-28-2024, 08:48 PM



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