HP 50g Double factorial
|
05-01-2019, 05:05 PM
(This post was last modified: 05-01-2019 09:26 PM by Giuseppe Donnini.)
Post: #6
|
|||
|
|||
RE: HP 50g Double factorial
Here's another solution:
Considering that n!! is equivalent to n·(n−2)·(n−4)· ... ·1 for every positive integer n ≠ 0 (odd or even), all it needs is a simple loop which calculates the next factor and multiplies it with the running product. 1 @ Initialize result. SWAP 2 FOR f @ Loop down from n to 2. f * @ Multiply with current factor. -2 STEP @ Decrement factor by 2 ; repeat until factor < 2. Taking into account the special case where n = 0 , we finally have: Code:
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)