Post Reply 
fraction program hp 28s?
06-24-2024, 07:39 PM (This post was last modified: 06-24-2024 08:18 PM by C.Ret.)
Post: #9
RE: fraction program hp 28s?
(06-23-2024 06:08 PM)Rafa Wrote:  Many thanks, i tried your program and it works perfectly! i intend to look at it again sometime to try to understand how does it work.

You're welcome !

My code does exactly the same thing as the original code you post but at each step, the values ​​A B and C are not put back into memory. They are simply placed in the stack. The misfortune is that they do not occupy the same level throughout the process. On the contrary, they are moved to be processed or are shifted under the effect of other treatments.

To see things more clearly, we need to draw a diagram for each instruction showing the contents and evolution of the stack. This requires a little work, but if necessary, I can prepare one with, for example, the value 2.34

(06-24-2024 03:03 AM)Gerson W. Barbosa Wrote:  Might be slow, depending on the factors. Also rather long.

I found in my archives the program that I used for the prime factor decomposition.

Like your program it is sometimes a little slow; although it depends a lot on the number to be broken down.
But clearly, it is much shorter. Note that using no string's instructions for composing the final algebraic expressions greatly shortens the length of the code and facilitates it.

I give below the listing of a version of my program. Everyone is free to draw inspiration from it for their own codes, comments or asking.
I must have a faster version somewhere using a wheel for the pseudo-prime generation. I can't find it anymore, it doesn't matter, it's also much longer than this version:


« 'a' SWAP 2
  WHILE DUP2 SQ ≥
  REPEAT
    'b' ROT 0
    WHILE SWAP 4 PICK DUP2 MOD NOT
    REPEAT
      / SWAP 1 +
    END
    DROP 5 ROLLD ROT 4 ROLLD
    IF DUP THEN  ^ 1 4 PICK EXSUB *
          ELSE  DROP2  END
    ROT ROT 1 +
  END
  DROP * 1 1 EXSUB »


Example :
45 ⇒ '1*3^2*5'
107 ⇒ '1*107'
1987587504 ⇒ '1*2^4*3^3*7*17*23*41^2'
350697021041 ⇒ '1*23^7*103'



P.S.: I found a commented version but in French. If anyone is interested, I will post a translated version here.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
fraction program hp 28s? - Rafa - 06-21-2024, 12:24 PM
RE: fraction program hp 28s? - C.Ret - 06-22-2024, 08:51 PM
RE: fraction program hp 28s? - Rafa - 06-23-2024, 06:08 PM
RE: fraction program hp 28s? - Peet - 06-22-2024, 10:44 PM
RE: fraction program hp 28s? - Rafa - 06-23-2024, 06:52 PM
RE: fraction program hp 28s? - Rafa - 06-23-2024, 06:43 PM
RE: fraction program hp 28s? - C.Ret - 06-24-2024 07:39 PM
RE: fraction program hp 28s? - Rafa - 06-25-2024, 01:36 PM
RE: fraction program hp 28s? - C.Ret - 06-25-2024, 05:27 PM
RE: fraction program hp 28s? - Rafa - 06-25-2024, 07:46 PM



User(s) browsing this thread: 2 Guest(s)