Post Reply 
RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
06-01-2019, 05:02 AM
Post: #4
RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
(06-01-2019 04:43 AM)Gerson W. Barbosa Wrote:  Yes, 155.4 seconds (base 10), or 155.4 ms per prime, but that’s not linear. For 100 primes it takes 7.38 seconds or about 13.5 primes per second. Anyway, that’s an improvement over my first attempt. Hopefully there’s still a better way.

Here's a fairly brute-force method:

Code:
\<<
   0. 9. NDUPN \->ARRY
   5
   ROT
   1 SWAP START
      NEXTPRIME
      SWAP OVER
      I\->R 10. MOD
      DUP2
      GET 1. + PUT
      SWAP
   NEXT
   DROP
   DUP 1. GET SWAP
   DUP 3. GET SWAP
   DUP 7. GET SWAP
   9. GET
   4. \->LIST
\>>

The result for an input of 1000. is { 245. 253. 256. 246. }, and on my 50g takes about 41s to complete. Note that I'm using approximate numbers here instead of exact to shorten the time a bit.
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) - DavidM - 06-01-2019 05:02 AM



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