HP-42S (Free42, DM-42) mini-challenge – Wallis Product
|
07-05-2020, 02:07 AM
Post: #7
|
|||
|
|||
RE: HP-42S (Free42, DM-42) mini-challenge – Wallis Product
.
Hi, Gerson: (07-04-2020 04:42 PM)Gerson W. Barbosa Wrote: Least number of steps then least number of bytes, including a 2-character label, wins. A pity, should you have included a "fastest running time" win condition this "let's-think-out-of-the-box" concoction o'mine would've surely won, as its running time is about the same regardless of the input: [19-step, 36-byte program] 01 LBL "WP" 02 STO ST Y 03 N! 04 X^2 05 RCL ST Y 06 STO+ ST X 07 N! 08 / 09 X^2 10 2 11 2 12 RCLx ST T 13 STO+ ST X 14 Y^X 15 * 16 0.5 17 RCL+ ST Z 18 / 19 END Some Examples (run in Free42) 1 XEQ “WP” -> 2.66666666667 10 -> 3.06770380664 123 -> 3.13523960403 which virtually match your results. As stated, the time is about the same whatever the argument, i.e., extremely fast, and it leaves the original contents of X when the program is run (i.e., the argument keyed in) in stack Y, Z and T. However, it's limited to those arguments that won't overflow the calculation, mostly the factorials, and a few steps can surely be shaved here and there, but I'm just too sleepy right now. :O Thanks for the nice mini-challenge, I saw it at 4:00 a.m. and it was just what I needed before going to bed. Have a nice weekend. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)