Hi all,
While waiting for the incoming S&SMC#13, those of you fortunate enough to
own an HP-15C (physical or emulated/simulated) might want to check any alleged 15C-guru abilities with this
15C-specific mini-challenge:
Write a routine as short and fast as possible to find integer solutions (a,b,c) of:
a2 + b2 = cNfor any given integer exponent N >= 2
Your routine must assume that the stack has been loaded like this upon calling it:
Z: some control valuewhere the control values are arbitrary user-supplied integer values that your
Y: some control value
X: N
routine must use somehow to generate solutions so that, for
different control values, different solutions are usually generated, in a repeatable way.
Depending on your algorithm, they might be initial ranges for a search, or
"seed" values for some computation or whatever, as long as they ensure variety and provide some control on the solutions produced.
Your routine must find out exactly *one* solution (which
should depend on the user-supplied control values and N, of course), and must output the resulting integer values (a, b, c). Of course, you should aim to produce non-trivial solutions, at least for
the vast majority of control values even if certain combinations do occasionally result in some trivial solution.
A sample run for N=5 would be something like this:
p1 [ENTER] p2 [ENTER]where p1 and p2 are some control values that your algorithm uses to produce the solution (1121, 404, 17). Indeed we have:
5 [A] -> 1121
[R/S] -> 404
[R/S] -> 17
11212 + 4042 = 1256641 + 163216 = 1419857 = 175Specifying different control values, q1 and q2 should produce a different solution, say:
2231912 + 1195122 = 1455i.e.: 49814222481 + 14283118144 = 64097340625
Remember that your routine must work for arbitrary integer values of N >= 2, not just 5 (within the HP-15C accuracy and range limitations, of course). In a few days I'll post my own solution, which is a small, HP-15C-specific 12-step
routine (not counting LBL A or RTN). Let's see yours !
Note: Although both this mini-challenge and my solution are HP-15C-specific, solutions for other models are welcome, of course.
Best regards from V.