Post Reply 
fraction program hp 28s?
06-24-2024, 03:03 AM
Post: #8
RE: fraction program hp 28s?
(06-23-2024 06:43 PM)Rafa Wrote:  And do you also happen to have a prime factorisation program for the 28s?

This was written originally for the HP-28S. Hopefully no 48G-only instructions.

Code:


DIR
  FPRM
  \<< DUP
    IF PRTST NOT
    THEN 1 SF 2 "'" ROT ROT DCMP 1 + 1 CF
      WHILE OVER 1 \=/
      REPEAT DCMP 2 +
      END DROP2 DUP SIZE 1 - 1 SWAP SUB "'" + STR\->
    END
  \>>
  DCMP
  \<< DUP2 MOD
    IF NOT
    THEN DUP \->STR 0
      DO 1 + 4 ROLL 4 ROLL SWAP OVER / DUP2 6 ROLLD 5 ROLLD SWAP MOD
      UNTIL
      END DUP
      IF 1 \=/
      THEN SWAP "^" + SWAP \->STR +
      ELSE DROP
      END ROT DUP
      IF PRTST
      THEN DUP 2 - 1 FS? + ROT 4 ROLL DROP
      ELSE ROT ROT
      END "*" + 4 ROLL SWAP + ROT ROT
    END
  \>>
  PRTST
  \<< DUP 2 / FP
    IF
    THEN DUP \v/ 1
      DO 2 + 3 DUPN SWAP OVER
      UNTIL < ROT ROT MOD NOT OR
      END SWAP DROP MOD NOT
    END NOT
  \>>
END

Might be slow, depending on the factors. Also rather long.

1987587504 FPRM ->

'2^4*3^3*7*17*23*41^2'
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? - Gerson W. Barbosa - 06-24-2024 03:03 AM
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: 1 Guest(s)