Post Reply 
HP 50g Programming Competition: How Many Partitions of an Integer in 4 Squares
04-15-2018, 02:07 PM
Post: #10
RE: HP 50g Programming Competition: How Many Partitions of an Integer in 4 Squares
I've got it further improved and significantly smaller:

Code:
%%HP: T(3)A(R)F(.);
@ Jacobi, by Thomas Ritschel
@ number of representations
@ Jacobi's four-square theorem
@ idea based on Joe Horn's \Gs
\<< FACTORS DUP SIZE
  IF 0 >
  THEN R\->I OBJ\-> 1 SWAP 1. SWAP 2. /
    START PICK3 DUP
      IF 2 ==
      THEN ROT DROP 1 UNROT
      END ROT 1 + ^ 1 - ROT 1 - / *
    NEXT
  ELSE DROP 1
  END 8 *
\>>

Runtime for 720^20 and '720^20' is slightly slower: 0.69 and 0.72 secs, respectively.
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-15-2018 02:07 PM



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