Post Reply 
RPL second impressions (HP 28)
07-02-2018, 12:05 AM
Post: #50
RE: RPL second impressions (HP 28)
(07-01-2018 11:39 PM)Thomas Klemm Wrote:  
(07-01-2018 11:09 PM)Gerson W. Barbosa Wrote:  The lack of DOERR is also a problem. It’s been suggested to provoke an error, like 0 INV, for instance, but I have yet to figure out where.

COMPOSITE?
Code:
« DUP 1 - → a s d n m
  « a d n POWER
    IF DUP 1 ==
    THEN DROP 0
    ELSE
      IFERR s
        WHILE DUP
        REPEAT
          SWAP
          DUP m ≠ INV
          DROP
          DUP n TIMES
          SWAP 1 -
        END
      THEN SWAP DROP SWAP DROP
      ELSE DROP2 1
      END
    END
  »
»

PRIME?
Code:
« → n 
  « 0 n 1 -
    WHILE DUP 2 MOD NOT
    REPEAT
      SWAP 1 +
      SWAP 2 /
    END → s d
    « { 2 13 23 1662803 }
      IFERR
        WHILE DUP SIZE
        REPEAT
          DUP HEAD s d n COMPOSITE? NOT INV
          DROP
          TAIL
        END
      THEN SWAP DROP
      ELSE DROP 1
      END
    »
  »
»

HTH
Thomas

Thanks!

177777773: 65 seconds
999999999989: 97.5 seconds

On the HP-28S, HEAD & TAIL replaced with David’s suggestions.

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 - 07-02-2018 12:05 AM
RE: RPL second impressions (HP 28) - ttw - 07-04-2018, 10:52 PM



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