(32SII/DM32) Prime Factorization (edit) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (32SII/DM32) Prime Factorization (edit) (/thread-20854.html) |
(32SII/DM32) Prime Factorization (edit) - Eddie W. Shore - 11-17-2023 03:41 AM Instructions: 1. Enter a positive integer on the X stack. 2. Run the program (XEQ P) and a prime factor is displayed. Press [ R/S ] to continue. At this point the calculator is set to FIX 0 mode. Repeat step 2. 3. The program ends when the integer reappears. The calculator is reset to FIX 4. 3 labels are needed. Note: One instruction has been corrected, thank you, Thomas Klemm! Code: P01 LBL P Labels used: P, B, A Variables: F (factor), A, B Examples 26: 2, 13, 26 (26 = 2 × 13) 89: 89 (89 is prime) 175: 5, 5, 7, 175 (175 = 5^2 × 7) 1020: 2, 2, 3, 5, 17, 1020 (1020 = 2^2 × 3 × 5 × 17) RE: (32SII/DM32) Prime Factorization - Namir - 11-17-2023 04:18 AM Nice program Eddie! Looks like it can easily be converted to run on other (incuding older) HP calculators. Namir RE: (32SII/DM32) Prime Factorization - DA74254 - 11-17-2023 08:50 AM Either I've done something completely wrong or there is a bug in the program. No matter what I put in, it'll return "2,". Pressing r/s results in the originally entered integer to return to the stack. Hitting xeq p just continues to return "2,". Running xeq p with "0" on the stack returns "divide by 0". Yes, I've quadruplechecked the program listing. It's correct. No, nothing else in the calc. Brand new state and all vars cleared. State file in "code" tag and also attached. Code:
RE: (32SII/DM32) Prime Factorization - Thomas Klemm - 11-17-2023 08:18 PM (11-17-2023 08:50 AM)DA74254 Wrote: Either I've done something completely wrong or there is a bug in the program. (11-17-2023 03:41 AM)Eddie W. Shore Wrote: That should rather be: Code: B03 RCL÷ F Here's a program for the HP-42S: Code: 00 { 42-Byte Prgm } I made a few minor adjustments but there's still room for improvements. RE: (32SII/DM32) Prime Factorization (edit) - Eddie W. Shore - 11-18-2023 03:36 PM Thank you, Thomas! I have corrected the typo on the original post. RE: (32SII/DM32) Prime Factorization (edit) - Eddie W. Shore - 11-18-2023 03:39 PM (11-17-2023 04:18 AM)Namir Wrote: Nice program Eddie! Looks like it can easily be converted to run on other (incuding older) HP calculators. Thank you, Namir! The program was ported from a HP 15C version. |