HP Forums

Full Version: (35S) Reverse Digits Programme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The programme REVERSO takes integer input & returns the digit reversed integer.

eg Input 123 returns 321.

1 LBL R
2 0
3 x<>y
4 x=0?
5 GTO R009
6 10*REGY+RMDR(REGX,10)
7 IDIV(REGY,10)
8 GTO R004
9 R↓
10 RTN
A slight optimization of REVERSO, one line smaller & faster for entry > 0, slower for 0. Why bother to optimize? speed difference is negligible, 35S has more than enough memory...it's just that I feel an irritation when I see the waste looking up at me from the page.

1 LBL R
2 0
3 x<>y
4 10*REGY+RMDR(REGX,10)
5 IDIV(REGY,10)
6 x≠0?
7 GTO R004
8 R↓
9 RTN
Reference URL's