Post Reply 
RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
07-01-2019, 01:52 PM
Post: #11
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
Mine turned out to be very close to John's solution:

Code:


*** Anti-spoil (scroll down to see) ***
















(classic RPL version - 108 bytes in newRPL)
«
  → 
    M « 2 1 M FOR 'K' DUP 1 K 2 * START
        NEXTPRIME 
      NEXT
    NEXT
    M 1 + →LIST 
  »
»

(newRPL dialect - 96 bytes )
«
  'M' LSTO 2 1 M FOR 'K' DUP 1 K 2 * START
      NEXTPRIME 
    NEXT
  NEXT
  M 1 + →LIST 
»

We are at 96 bytes for newRPL, can't beat the 50g with classic RPL in size (never will), but in speed is a different story...
Runs the 99 case in 172 msec (second run), or 489 msec for the first run (which runs at 6 MHz for some time before the "turbo" kicks in). Runs the 150 case in 5.61 seconds (second run) and 5.98 sec for the first run, in this case the difference between the first/second run becomes a lot less relevant.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g) - Claudio L. - 07-01-2019 01:52 PM



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