Post Reply 
RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
06-01-2019, 03:29 PM
Post: #12
RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
(06-01-2019 02:38 PM)Valentin Albillo Wrote:  
(06-01-2019 08:51 AM)Carsen Wrote:  Here's my take on the challenge. The algorithm is very straightforward. Get the next prime number, put it in a string, retrieve the last digit in the string [...]

That's too inefficient, you don't need to deal with strings to extract the last digit of a non-negative integer number, just do a MOD 10, which will be much simpler and many times faster.

I had tried MOD 10 too, especially because it would reduce the byte count, but for a reason I can't explain the running time changed from 155.4 seconds to 1677.1 seconds.

(06-01-2019 02:38 PM)Valentin Albillo Wrote:  I'd post one line of trivial HP-71B code using that approach but this challenge is for RPL machines and I don't want to intrude. Smile

Please do it if you wish, that's no intrusion. I mentioned RPL and those particular models because they have ISPRIME built-in (not sure about the HP-71B or its Math ROM).

Best regards,

Gerson.
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:29 PM



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