Factor
|
04-18-2014, 06:10 PM
(This post was last modified: 04-22-2014 01:01 PM by Thomas Klemm.)
Post: #1
|
|||
|
|||
Factor
Find the factors of a number. Program for the HP-42s.
Example: 167,699,497 XEQ "FACTOR" 7×3851×6221 |
|||
04-20-2014, 07:02 AM
Post: #2
|
|||
|
|||
RE: Factor
Is this for the 41, Thomas? I ran into trouble with step 38, which appears to do recall arithmetic with a stack register, something my 41CX seems unwilling to do.
--- Les [http://www.lesbell.com.au] |
|||
04-20-2014, 07:48 AM
Post: #3
|
|||
|
|||
RE: Factor
(04-20-2014 07:02 AM)Les Bell Wrote: Is this for the 41, Thomas?Nah, the 42S. Quote:I ran into trouble with step 38, which appears to do recall arithmetic with a stack register, something my 41CX seems unwilling to do.Replace it with: Code: 38 RCL Y But then you have to replace lines 05-07 at the beginning as well: Code: 05 ENTER HTH Thomas |
|||
04-20-2014, 08:44 AM
(This post was last modified: 04-20-2014 09:01 AM by Les Bell.)
Post: #4
|
|||
|
|||
RE: Factor
(04-20-2014 07:48 AM)Thomas Klemm Wrote: Nah, the 42S. Yes, I twigged to that a few minutes later. Thanks for the update - it will save me a bit of fiddling! Also, for any other 41 users: line 41 becomes "FRC" on the 41. And the AIP instruction on line 29 is implemented by the AIP function in the Advantage module, presumably appending the integer part of X to the Alpha register. --- Les [http://www.lesbell.com.au] |
|||
04-21-2014, 02:48 PM
(This post was last modified: 04-21-2014 03:50 PM by Dieter.)
Post: #5
|
|||
|
|||
RE: Factor
(04-20-2014 07:48 AM)Thomas Klemm Wrote:(04-20-2014 07:02 AM)Les Bell Wrote: Is this for the 41, Thomas?Nah, the 42S. Since this is the HP41 Software Library, here is a version that runs on all 41s. Here is the code: Code: 01 LBL "FACTOR" This version includes a short routine at LBL 04 that replaces the AIP command. There are two synthetic instructions (RCL d and STO d) that save and restore the display state. If you do not know how to handle this, simply replace that subroutine with... Code: 51 LBL 04 There also is an additional AVIEW in line 36 so that you can watch the result build up. ;-) Omit it if you don't like it. Both program versions have a slight design flaw: they stop with pending subroutine calls, to that they cannot end with a RTN or END and a final PROMPT is required. I did not take a closer look at the way FACTOR works, so I left it that way. Dieter Edit: corrected an error in the listing. |
|||
04-21-2014, 04:50 PM
Post: #6
|
|||
|
|||
RE: Factor
(04-21-2014 02:48 PM)Dieter Wrote: Since this is the HP41 Software LibrarySorry if I placed the program in the wrong section, but I just didn't find any programs for the HP-42S at the General Software Library.And then it says here: Quote:Contributed programs for the HP-41C Family.So I thought the HP-42S might belong to this family. If this is a problem the thread can be moved. Quote:here is a version that runs on all 41sThanks for taking the time to put that together. Quote:I did not take a closer look at the way FACTOR worksNothing fancy, similar to Factors and Primes for the HP-67. It was mentioned in a recent thread:What is the best BASIC Pocket Computer. I wrote that program a while ago so I thought to myself, I can just as well upload it here. Cheers Thomas |
|||
04-22-2014, 06:03 AM
Post: #7
|
|||
|
|||
RE: Factor
(04-21-2014 04:50 PM)Thomas Klemm Wrote: Sorry if I placed the program in the wrong section, but I just didn't find any programs for the HP-42S at the General Software Library.And then it says here: No problem as far as I can see, Thomas - I was just thrown a little when I started keying the program in and then came across the recall arithmetic; I was wondering whether it might be using synthetics (which I haven't played with, much). Perhaps a useful guideline might be to specify at the top which particular member of the 41 family a program was developed on or for, as well as any other requirements (e.g. for modules or peripherals). Incidentally, I pulled a WP-34S out of my drawer and easily adapted your program to run on that, too - so the "family" label seems quite appropriate. Now, about your "Solving a Single Congruence Equation" listing . . . --- Les [http://www.lesbell.com.au] |
|||
04-22-2014, 07:45 AM
Post: #8
|
|||
|
|||
RE: [HP-42s] Factor
(04-22-2014 06:03 AM)Les Bell Wrote: Perhaps a useful guideline might be to specify at the top which particular member of the 41 family a program was developed on or for, as well as any other requirements (e.g. for modules or peripherals).Added [HP-42S] to the subject. Quote:Now, about your "Solving a Single Congruence Equation" listing . . .I know. That won't be easy without RCL-arithmetic. Cheers Thomas |
|||
04-22-2014, 09:08 AM
Post: #9
|
|||
|
|||
RE: [HP-42s] Factor
(04-22-2014 07:45 AM)Thomas Klemm Wrote: Added [HP-42S] to the subject.Can I suggest putting the calculator type after the program name, or even just in the top of the post body somewhere? It doesn't seem as important as the program name, and the square brackets here are messing up the alphabetical listing. Quote:Now, about your "Solving a Single Congruence Equation" listing . . .I know. That won't be easy without RCL-arithmetic. [/quote] Not to worry. If I need it, I'll figure it out. --- Les [http://www.lesbell.com.au] |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)