The Museum of HP Calculators

HP Forum Archive 17

 35s - fun algebraic tricks #2Message #1 Posted by Gene Wright on 13 July 2007, 6:35 p.m. Here's another type of fun algebraic trick that can be used in **RPN** programs. Suppose you have a 3-digit positive number in X and you want to determine the "sum of the digits" of the number. The program below will do this and not destroy the stack! LBL A press EQN RDMR(REGX,10)+RMDR(IDIV(REGX,10),10)+RMDR(IDIV(REGX,100),10) RTN The original stack is pushed to Y, Z and T. If you want to save Y, Z and T instead, then do a RDN after LBL A and change the RMDR line to point at REGT rather than REGX). 69 bytes used, but very handy to preserve the stack. I personally think these types of features will be very powerful in future programs. RMDR is the remainder function, IDIV is integer division, and REGX is the way the 35s refers to the value in register X. REGT would point at the value in the T register. When a function (like RMDR and IDIV) are presented in an algebraic context, it prompts the function name along with the open/close parentheses and a comma supplied (if needed to separate two arguments). To move across the comma to enter the second argument, you press the right arrow key. It's not hard to get used to at all. I'd better stop or this will be yet another learning module. Gene

 Re: 35s - fun algebraic tricks #2Message #2 Posted by Les Wright on 13 July 2007, 6:52 p.m.,in response to message #1 by Gene Wright Gee, this is becoming a regular Nerds Anonymous meeting, isn't it? ;)

 Even better ...Message #3 Posted by Don Shepherd on 13 July 2007, 7:08 p.m.,in response to message #1 by Gene Wright sigma(i:0:log(n):1:mod(idiv(n:10^i):10)) Works for any length number.

 Re: Even better ...Message #4 Posted by Bruce Bergman on 13 July 2007, 7:10 p.m.,in response to message #3 by Don Shepherd Don, I just KNEW I'd see you here in this thread. :-) :-) thanks, bruce

 Re: Even better ...Message #5 Posted by Gene Wright on 13 July 2007, 7:21 p.m.,in response to message #3 by Don Shepherd Hmm. Sigma doesn't seem to work on the 35s in equation mode. :-) Wish it DID, but...

 Re: Even better ...Message #6 Posted by Bruce Bergman on 13 July 2007, 7:36 p.m.,in response to message #5 by Gene Wright What? I thought the 35s had the full solver functionality? Is that not true? Or has it been brain-downed? thanks, bruce

 Re: Even better ...Message #7 Posted by Don Shepherd on 15 July 2007, 7:25 a.m.,in response to message #6 by Bruce Bergman Bruce, I notice that Sigma is not available in the 33s, which is probably why it is not in the 35s.

Go back to the main exhibit hall