Post Reply 
HP 50g Programming Competition: How Many Partitions of an Integer in 4 Squares
04-16-2018, 01:19 PM
Post: #17
RE: HP 50g Programming Competition: How Many Partitions of an Integer in 4 Squares
By dropping the ability to treat algebraic inputs and some minor changes I got my version slightly faster, but it still doesn't reach the speed of your program, Gerald, at the smaller inputs.

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
\<<
  DUP
  IF
  THEN 8 SWAP FACTORS DUP SIZE
    IF
    THEN R\->I OBJ\-> PICK3
      IF 2 ==
      THEN SWAP DROP 1 SWAP
      END
      1 1. ROT 2. / DUP
      IF
      THEN
        START PICK3 ROT 1 + ^ 1 - ROT 1 - / *
        NEXT *
      ELSE DROP2 DROP
      END
    ELSE DROP
    END
  ELSE DROP 1
  END
\>>
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-16-2018 01:19 PM



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