Post Reply 
RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
06-02-2019, 09:18 PM (This post was last modified: 06-02-2019 10:12 PM by Gilles.)
Post: #20
RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
Here a newRPL version :

Code:

«
  0 9 NDUPN →LIST → stat 
  « 
   5 SWAP 1 SWAP START
      NEXTPRIME DUP 0 0 DIGITS 'stat' SWAP DUP2 GET 1 + PUT 
    NEXT
    { 1 3 7 9 } « 'stat' SWAP GET  »  MAP 
  »
»
With the simulator on my PC :

10'000 -> { 2485 2515 2508 2492 } in 0.01s
100'000 -> { 24968 25008 25015 25009 } in 0.78s
1'000'000 -> { 249934 250109 250017 249940 } in 23.2 s
10'000'000 -> { 2499756 2500208 2500284 2499752 } in 963s

I notice that in newRPL :

- LIST is little faster than ARRAY
- Local variable is faster than big juggles with the stack
- MAP is little faster than DOSUBS (MAP is very slow in UserRPL)
- There is a problem with this program on my HP50g hdw (reported to Claudio)
- Albert Chan suggest in a post to optimise by counting only 1,3,7's, and derive the count of 9's, but this need a test and there is no significant gain. ( I probably do a typo error in my previous post for the output , I will verify)
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) - Gilles - 06-02-2019 09:18 PM



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