(32SII/DM32) Prime Factorization (edit)
|
11-17-2023, 03:41 AM
(This post was last modified: 11-18-2023 03:36 PM by Eddie W. Shore.)
Post: #1
|
|||
|
|||
(32SII/DM32) Prime Factorization (edit)
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) |
|||
11-17-2023, 04:18 AM
Post: #2
|
|||
|
|||
RE: (32SII/DM32) Prime Factorization
Nice program Eddie! Looks like it can easily be converted to run on other (incuding older) HP calculators.
Namir |
|||
11-17-2023, 08:50 AM
Post: #3
|
|||
|
|||
RE: (32SII/DM32) Prime Factorization
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:
![]() Esben 28s, 35s, 49G+, 50G, Prime G2 HW D, SwissMicros DM42, DM32, WP43 Pilot Elektronika MK-52 & MK-61 |
|||
11-17-2023, 08:18 PM
Post: #4
|
|||
|
|||
RE: (32SII/DM32) Prime Factorization
(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. |
|||
11-18-2023, 03:36 PM
Post: #5
|
|||
|
|||
RE: (32SII/DM32) Prime Factorization (edit)
Thank you, Thomas! I have corrected the typo on the original post.
|
|||
11-18-2023, 03:39 PM
Post: #6
|
|||
|
|||
RE: (32SII/DM32) Prime Factorization (edit) | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)