(33s) OEIS A2113: Palindromes in Natural Order - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (33s) OEIS A2113: Palindromes in Natural Order (/thread-18639.html) |
(33s) OEIS A2113: Palindromes in Natural Order - Gerald H - 08-05-2022 12:54 PM Edit: 2022-08-06 Simplification of lines 4 & 5 of programme P. Some years ago I wrote a programme for 49G to produce the same numbers - not so difficult if you have possibility of treating numbers as text. https://www.hpmuseum.org/forum/thread-9988.html The poor 33s only has numerical capabilities so I have risen to the challenge. The programme P uses three helper programmes T, H & R shown below P. All of the four programmes preserve the stack. (Let's see you do that on 41C or 42S!) Suggestions for improvements welcome. Takes a natural number N from the stack & returns A2113(N) to stack, Nth palindrome in natural order. Does not disturb stack. Code: 1. LBL P P: LN = 41 V: LN =28 Q: LN = 132 X: LN =24 U: LN = 35 Y: LN = 18 Head. Erases all but first digit of stack level X. Does not disturb stack. Code: 1. LBL H Tail. Erases first digit of stack level X. Does not disturb stack. Code: 1. LBL T Reverso. Reverses the order of digits in stack level X. eg 1234 becomes 4321. Does not disturb stack. Code: 1. LBL R RE: (33s) OEIS A2113: Palindromes in Natural Order - Gerald H - 09-02-2022 02:50 AM Following this thread https://www.hpmuseum.org/forum/thread-18742.html a better version of HEAD: Code: 1. LBL X |