RPL second impressions (HP 28)
|
07-01-2018, 12:41 PM
(This post was last modified: 07-01-2018 12:50 PM by Gerson W. Barbosa.)
Post: #36
|
|||
|
|||
RE: RPL second impressions (HP 28)
(07-01-2018 03:49 AM)Thomas Klemm Wrote:(06-28-2018 08:48 PM)mdunn Wrote: All previous ones don’t work either when n<4. When I said "all previous ones" that included my original program. As I said, that limitation was irrelevant to my purpose, but if I want to use it as a primality test then I think it should handle all valid arguments, even if we know 1 is not prime and 2 and 3 are. An easy way to do it is by means of a patch (thus, an inelegant solution) to be added at the beginning of the program: « IF 3 DUP2 ≤ THEN SWAP - ELSE DROP END IF DUP 2 MOD THEN → n « IFERR 3 n √ FOR d n d MOD INV DROP 2 STEP THEN ELSE 1 END » ELSE NOT END » I don't use the 28S anymore for prime factorization, as the built-in FACTOR on the 50g does it much faster, but if the 28S were my only calculator I would use your optimized version without my unnecessary patch. FWIW, here is my full original HP-28S program: Code:
Thank you very much for your advices and improvements. Gerson. PS: Quote:All previous ones don’t work either when n<4. That was written by myself, not by mdunn. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)