|HP-15C (11C/34C/42S/etc) Arguably Useful Mini-Challenge|
Message #1 Posted by Valentin Albillo on 24 Nov 2003, 11:16 a.m.
After some months of comforting absence, here's a new Arguably Useful Mini-Challenge
for the HP-15C.You can also use other HP models such as the
HP-11C, HP-34C, HP42S, etc, though my solutions and timing will be particularized explicitly for the HP-15C.
The challenge has practical applications, and goes like this:
Write a subroutine (LBL A ... RTN) that given an integer N (where N > 0) in the display,
it will return to the display the value of f(N), where:
f(N) = 1 x 3 x 5 x ... x (2*N-3) x (2*N-1)
thus, for instance, if N = 4 then
<------------ N terms ------------>
f(4) = 1 x 3 x 5 x 7 = 105
The main design goal for the routine is for it to be
as fast as possible, (specially
for large N, such as N > 30) and subject to that, to be
as short as possible, to minimize resources (registers,
flags, etc) used or have some other desirable properties.
Under the conditions given, there's a solution for the HP-15C in just 12 steps
(counting LBL A and RTN) which takes 2.7 seconds for N = 52.
I'll give my solutions within 2 days or so, discussing the
relative advantages of each. Meanwhile, let's see what
you can do with your trusty HP and your ingenuity. :-)
Best regards from V.
Edited: 24 Nov 2003, 11:23 a.m.