Post Reply 
HP 50g Double factorial
01-27-2024, 05:57 AM
Post: #19
RE: HP 50g Double factorial
Hello

Just for the sake of using SEQ and ΠLIST:

Code:
<< → n
    << n 2 MOD
       { :: n :: n                 @ if n is even: 
         1 n 2 SEQ }                @ a list from 1 to n is created. 
       { :: n 1 − :: n             @ if n is odd:
         0 n 2 SEQ                  @ a list from '-1' to 'n − 1' is created.
         1 ADD                       @ adds 1 to each element of the list
         DUP                           @ duplicates the list (now from 0 to n)
         NOT                             @ new list: 0 becomes 1 ; others values become 0 
         ADD } IFTE                        @ adds the 2 lists, element by element
       ΠLIST                       @ returns the product of the elements of the list = the double factorial of n
    >>
>>

To avoid the {1} bug with ΠLIST, ΠLIST can be replaced by LPROD (from ListExt library).

:: are used to replace ' ' which can not be used in a list.

Or more conventionally, ' ' within chevrons:

<< 'n' … >> << 'n − 1' … >> IFTE

Bruno
Sanyo CZ-0124 ⋅ TI-57 ⋅ HP-15C ⋅ Canon X-07 + XP-140 Monitor Card ⋅ HP-41CX ⋅ HP-28S ⋅ HP-50G ⋅ HP-50G
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)