Post Reply 
HP 50g Double factorial
01-27-2024, 09:33 PM
Post: #22
RE: HP 50g Double factorial
(01-27-2024 05:51 PM)FLISZT Wrote:  <<
{ 2 − } { 1 > } LWHL
1 +
@ To insert the missing 1 in the list.
LPROD
>>


… "et voilà" as (some) English speakers say (sometimes). Wink

0 returns 1
1 returns 1
2 returns 2
3 returns 3
4 returns 8
5 returns 15

14 yields 645 120
15 yields 2 027 025
etc.

In this case, you don't actually need the "1 +" after the LWHL command, since multiplying by 1 has no impact on the final result. It doesn't hurt anything for it to be there, of course. But it's not needed.

Note that this method isn't particularly good with large n, since it requires enough free memory for the entire list of multiplicands to be created en masse, and also the program essentially has to iterate the large list twice behind the scenes (once when building, then a second time for computing the product).

John Keith's example covers most everything you could want here, and is much more efficient. I just wanted to point out the use of LWHL and LPROD in this context, which shortens the code significantly. As is frequently the case, though, large lists take lots of memory and can be slow to process.
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)