Post Reply 
(33s) OEIS A4186: Digits in Descending Order
09-25-2022, 04:18 PM (This post was last modified: 09-25-2022 04:38 PM by C.Ret.)
Post: #6
RE: (33s) OEIS A4186: Digits in Descending Order
Hello,

This weekend, I found a way to rent a friend's HP-35S along with its owner's manual. What a funny machine!

It is with great difficulty that I managed to adapt my second algorithm to it, the one that gives the integers with the numbers sorted in ascending and descending order.

Be indulgent, this is my first program on HP-35S; it is it is intended to be used in RPN mode and with the ALL display option.

Code:
O001 ►LBL O       O011  x<>y        O021  1           O031  ×           O041  1           O051▫ STO I     
O002  CLVARS      O012▪ x<>(i)      O022  STO+ J      O032  RCL+(i)     O042  STO- I      O052▫ 2         
O003  STO N       O013  FS? 1       O023  10¨x        O033  x<>y        O043  10¨x        O053▫ -         
O004  13          O014  CLx         O024  INT÷        O034  STO×(i)     O044  ×           O054▫ RTN       
O005  STO I       O015  x<y?        O025  x>0?        O035  R↑          O045  DSE J     
O006  STO(I)      O016  x<>y        O026  GTO O009    O036  RCL+(i)     O046  GTO O029  
O007  SF 1        O017  x<>(i)      O027▫ XEQ O049    O037  x<>y        O047  R↓        
O008  RCL N       O018  DSE I       O028  SGN         O038  R↓          O048  RTN    ■    
O009▫ XEQ O049    O019  GTO O012    O029▪ x<>y        O039  x<>y        O049▪ REGX      
O010  RMDR        O020  CF 1        O030  10          O040  R↑          O050▫ 12        

LBL O
CK=A4D8
LN=175

It's a bit long code but it has the advantage of using only one label (LBL O). Unlike the HP-41C version, it handles integers up to 12 digits which it temporarily stores in twelve anonymous registers using indirect addressing via the I register.

It also uses flag #1 because I couldn't find a simple instruction to reset or reserve the anonymous register range. The flag is used to reset the anonymous registers on the first pass. At the beginning of the code, I put 13 in the anonymous register (13) in order to 'reserve' without surprise the range (1) to (12).

It's a bit of a hassle on this machine, isn't it?
The keyboard is far too overloaded, I prefer, by far, to use my more sober HP-41C and with better organized registers.


3142 XEQ O ENTER
run a few seconds and display
1234
4321

The initial value 3142 is kept in the register N
This version clears all the registers. To preserve memory contents, please alter the code with the starter sequence:

Code:
O001 LBL O
O002 STO N
O003 13
O004 STO I
O005 STO(I)
O006 CLx
O007 STO J
O008 SF 1
...
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (33s) OEIS A4186: Digits in Descending Order - C.Ret - 09-25-2022 04:18 PM



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