Post Reply 
HP 50g Programming Competition: How Many Partitions of an Integer in 4 Squares
04-14-2018, 08:18 PM (This post was last modified: 04-14-2018 08:36 PM by Thomas Ritschel.)
Post: #5
RE: HP 50g Programming Competition: How Many Partitions of an Integer in 4 Squares
(04-14-2018 06:17 PM)Gerald H Wrote:  I have copied your programmes, Thomas, & for input

720^20

the programme returned

52175039830928864354013492999359544

in

1.42 sec.

In my test I had 720^20 as an algebraic object on stack level 1, e.g. entered as '720^20'.

However, when 720^20 is evaluated to 1401683395356260729391818575873415577600000000000000000000 first, and then the Jacobi program is called, I also get 52175039830928864354013492999359544 in about 1.4 sec.

It turns out, that it fails for some kind of algebraic terms like 'a^b' or 'a*b', but not all of them (e.g. '3*11' seems to work well).

To make it save, an 'EVAL' should be added to the Jacobi program:

Code:
%%HP: T(3)A(R)F(.);
\<< EVAL DUP 4 MOD
IF 0 ==
THEN DUP 4 / \Gs 32 * NEG
ELSE 0
END SWAP \Gs 8 * +
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 50g Programming Competition: How Many Partitions of an Integer in 4 Squares - Thomas Ritschel - 04-14-2018 08:18 PM



User(s) browsing this thread: 1 Guest(s)