Prime Factors - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP-41C Software Library (/forum-11.html) +--- Thread: Prime Factors (/thread-3899.html) |
Prime Factors - Dave Britten - 05-18-2015 06:10 PM In an attempt to rival Doom for the largest number of systems to which it's been ported, here's the usual HP 67 "mod 30" prime factors program for the 41C/CV/CX. Enter a positive integer, and XEQ FCTR. Press R/S to view each factor. Zero will be displayed when there are no more factors. Note this is a pretty straight port, and hasn't been fancied up with any 41-specific capabilities (yet). EDIT: Here's a slightly improved version with a couple optimizations, and multiplicity display for factors (e.g. 3^2, 7^3, etc). Code: 01 LBL FCTR RE: Prime Factors - Thomas Klemm - 05-18-2015 08:31 PM (05-18-2015 06:10 PM)Dave Britten Wrote: Note this is a pretty straight port, and hasn't been fancied up with any 41-specific capabilities (yet). You might have a look at a program for the HP-42s which uses the same idea. Cheers Thomas RE: Prime Factors - Dave Britten - 05-19-2015 02:58 AM (05-18-2015 08:31 PM)Thomas Klemm Wrote:(05-18-2015 06:10 PM)Dave Britten Wrote: Note this is a pretty straight port, and hasn't been fancied up with any 41-specific capabilities (yet). Thanks Thomas. Clever use of t-copy there. I see a couple things that could be issues for a 41 port: the use of recall arithmetic, as mentioned in that thread, AIP, which requires the appropriate module or alternative code, and the alpha register being limited to 24 characters. I don't recall the 42S alpha limit, but I think I remember it being larger. I changed my version a bit to display multiplicity of factors as they're found (3^2, 5^3, etc.) and also replaced the / FRC bits with MOD, which appears to be about 20% faster. I'll probably post the updated code tomorrow. |