Post Reply 
RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
06-01-2019, 03:41 PM
Post: #13
RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
Thank you all for your participation and for the interesting and efficient solutions.

Here are my rather convoluted ones:

Base 10:

Code:

%%HP: T(3)A(R)F(,);
\<< DUP { } SWAP 5 1 ROT
  START NEXTPRIME SWAP OVER \->STR DUP SIZE DUP SUB OBJ\-> + SWAP
  NEXT DROP 2 * 1 - \PILIST FACTOR \->STR "*" "''" SREPL DROP OBJ\-> 3 \->LIST LN { 5 13 17 } LN / EXPAND SWAP OVER \GSLIST - SWAP +
\>>

I had tried 10 MOD instead of \->STR DUP SIZE DUP SUB OBJ\-> above, but akwardly the running time would increase from 155.4 s to 1677.1 s, for 1000 primes.

Base 8:

Code:

%%HP: T(3)A(R)F(,);
\<< DUP OCT { } SWAP 2 1 ROT
  START NEXTPRIME SWAP OVER R\->B \->STR DUP SIZE 1 - DUP SUB OBJ\-> + SWAP
  NEXT DROP 8 - NEG \PILIST FACTOR \->STR "*" "''" SREPL DROP OBJ\-> 3 \->LIST LN { 3 5 7 } LN / EXPAND REVLIST SWAP OVER \GSLIST - +
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Gerson W. Barbosa - 06-01-2019 03:41 PM



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