Post Reply 
HP 50g: Programming Problem: Integer Partition in Palindromic Integers
02-19-2018, 04:39 PM (This post was last modified: 02-19-2018 04:42 PM by Gerald H.)
Post: #24
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers
Here is my version of Juan14's programme, now gives correct answers for any positive integer:

SIZE: 279.

CKSM: # 55A3h

Code:
« 0. SWAP
  WHILE SWAP 1. + SWAP DUP 9 >
  REPEAT DUP →STR DUP SREV OBJ→ 1 SAME
    IF
    THEN DROP 1 - SWAP 1
    ELSE DUP SIZE 2. / SWAP 1. PICK3 SUB DUPDUP 1. 5. PICK FLOOR SUB SREV + 4 PICK OVER OBJ→ <
      IF
      THEN DROP OBJ→ 1 - →STR DUP 1. 4. ROLL IP SUB SREV +
      ELSE UNROT DROP2
      END OBJ→ SWAP OVER - ROT SWAP
    END
  END DUP NOT
  IF
  THEN DROP 1. -
  ELSE SWAP
  END DUPDUP 2. + ROLLD →LIST SWAP R→I →TAG
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers - Gerald H - 02-19-2018 04:39 PM



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