Post Reply 
Programming Challenge: Palindromic Numbers on HP 50g
01-13-2018, 09:53 PM
Post: #5
RE: Programming Challenge: Palindromic Numbers on HP 50g
Very nice, Thomas, & here a slightly altered version which will deal with the entry 98765432167 & return the correct answer!

By the way, SAME is much faster than ==.

NTOK

Code:
« DUP 10 <=
  IF
  THEN 1 -
  ELSE DUPDUP 2
IQUOT SIZE R→I 1 -
10 SWAP ^ SWAP OVER
11 * >=
    IF
    THEN 10 * SWAP
OVER - SWAP OVER *
SWAP NREV +
    ELSE SWAP OVER
- DUP 10 IQUOT NREV
UNROT * +
    END
  END
»

NREV

Code:
« 0
  DO 10 * OVER 10
MOD + SWAP 10 IQUOT
SWAP OVER 0 SAME
  UNTIL
  END NIP
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming Challenge: Palindromic Numbers on HP 50g - Gerald H - 01-13-2018 09:53 PM



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