RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
|
06-01-2019, 04:08 PM
Post: #14
|
|||
|
|||
RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
(06-01-2019 03:41 PM)Gerson W. Barbosa Wrote: Thank you all for your participation and for the interesting and efficient solutions. That's an interesting approach, Gerson. I'm a little surprised it did as well as it did, considering the jumps into CAS commands you've got going on. MOD with approximate numbers is generally faster than MOD with exact integers on the 50g, which is the main reason I used the I→R 10. MOD construct in my original (and subsequent) programs. Yet another UserRPL take on this that is both shorter and faster: Code: \<< It definitely dives into the more obscure end of the pool, though. It keeps the counters on the stack instead of contained in composite, and converts the remainder directly into a stack level to determine which counter to increment. This one completes an input of 1000. in about 32s. Carsen's use of the case statement inspired me to take another look at the performance using that type of construct. I use case structures a lot in SysRPL, but tend not to in UserRPL because they always feel verbose in that environment for some reason. I made another stack-based attempt that uses a case structure for determining which counter to update: Code: \<< While the code size jumped up considerably, the performance actually improved using this method by a few seconds (29s). I also wanted to see how a SysRPL version would perform: Code: :: It essentially uses the same approach as the previous program, but finishes in about 19s. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)