Post Reply 
RPL second impressions (HP 28)
06-29-2018, 07:35 PM
Post: #22
RE: RPL second impressions (HP 28)
(06-29-2018 05:13 PM)Thomas Klemm Wrote:  
(06-29-2018 01:08 PM)Gerson W. Barbosa Wrote:  That's one of my first RPL programs (HP-28S, back in 1987), so it can surely be optimized a bit.

Using local variables avoids stack juggling. Otherwise the changes were only minor.

Code:
«
  IF DUP 2 MOD
  THEN
    DUP √ → n r
    « 1
      DO
        2 +
      UNTIL
        r OVER <
        OVER n SWAP MOD NOT
        OR
      END
      n SWAP MOD NOT
    »
  END
  NOT
»

Also, your version is faster: 201 seconds for testing 177777773 instead of 214 seconds (on the real 28S). This means my stack handling is not efficient. When properly done it should be faster than using local variables.

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:19 AM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:58 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 04:06 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 05:11 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 07:45 PM
RE: RPL second impressions (HP 28) - mdunn - 06-28-2018, 08:48 PM
RE: RPL second impressions (HP 28) - Gerson W. Barbosa - 06-29-2018 07:35 PM
RE: RPL second impressions (HP 28) - ttw - 07-04-2018, 10:52 PM



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