RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Printable Version +- HP Forums ( https://www.hpmuseum.org/forum)+-- Forum: HP Calculators (and very old HP Computers) ( /forum-3.html)+--- Forum: General Forum ( /forum-4.html)+--- Thread: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) ( /thread-13054.html)Pages: 1 2 |

RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Gerson W. Barbosa - 06-02-2019 10:43 PM
(06-01-2019 09:59 PM)Valentin Albillo Wrote: Hello, Valentin, Thank you very much for the HP-71B version, much appreciated! I’ve noticed, however, FPRIM() is not a standard HP-71B function. I assume it’s a LEX file, a Language EXtension file by what I can remember. So, my question – not addressed exclusively to you, but to whom else can answer it – is: what is the easiest way to implement it on the real HP-71B or at least on Emu71? Thanks in advance. Best regards, Gerson. RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Valentin Albillo - 06-02-2019 11:27 PM
. Hi, Gerson: (06-02-2019 10:43 PM)Gerson W. Barbosa Wrote: Thank you very much for the HP-71B version, much appreciated! The easiest way to implement it on the real HP-71B or on Emu71 is by plugging in the JPC ROM, which is where the FPRIM keyword and dozens of others reside, and that is what I always do with my HP-71B, because an HP-71B it's not a "real" HP-71B but an emasculated one unless you fit it with a Math ROM, a JPC ROM and an HP-IL ROM. Oh, and a 128 Kb CMT RAM module, for good measure. That's the power HP machine I use at all times and have been saying and advocating that much for the last 20+ years in this and the old forum, nothing new here. Frankly, I don't quite see why RPL machines can use this or that library all the time without anyone raising an eyebrow (me included) and the moment I use a "library" (a ROM) with my HP-71B someone goes and asks what is "the easiest way to implement it on the real HP-71B". Is my HP-71B unreal to you or what ? I take it that you don't use any libraries with your RPL models, then ? Best regards. V. . RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Gerson W. Barbosa - 06-03-2019 12:14 AM
(06-02-2019 11:27 PM)Valentin Albillo Wrote: The easiest way to implement it on the real HP-71B or on Emu71 is by plugging in the JPC ROM, which is where the FPRIM keyword and dozens of others reside, and that is what I always do with my HP-71B, because an HP-71B it's not a "real" HP-71B but an emasculated one unless you fit it with a Math ROM, a JPC ROM and an HP-IL ROM. Oh, and a 128 Kb CMT RAM module, for good measure. Here ✓ Math ROM ✗ JPC ROM ✓ HP-IL ROM ✓ 32 KB RAM Plus card reader, HP-9114B disk-drive and proper floppies, IP-IL cables. JPC ROM still missing... Best regards, Gerson. RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Carsen - 06-03-2019 03:49 AM
(06-01-2019 12:48 PM)grsbanks Wrote:(06-01-2019 08:51 AM)Carsen Wrote: ...test if the digit is a 1, 3, 7, 9, or none of the aboveHow could it be none of the above? Oops. You're right. A simple impetuous mistake on my part. (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 [...] Okay. That makes a lot of sense, especially after I single stepped (SST) through DavidM's first RPL program that he posted in this thread because he did exactly what you described Valentin. After reflecting other's variants of code, this exercise will remind me how useful the MOD function can be in programming because I never really use it. (06-01-2019 03:17 PM)Gerson W. Barbosa Wrote: Just two remarks: Nice! Save 3 seconds in Exact mode! I sure like that. I have a question on remark 1 Gerson. Why should my STR-> be replaced with an OBJ->? Thanks everyone! RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Valentin Albillo - 06-03-2019 04:25 AM
. G'day, Gerson, (06-03-2019 12:14 AM)Gerson W. Barbosa Wrote: JPC ROM still missing... Try this link: J-F Garnier's JPC ROM for the HP-71B. There you'll find a treasure trove full of all kinds of manuals, guides, docs and of course binary images that you can immediately use with most any emulators such as Emu71 and even Android ones for your phone. I'm using Version F in both Win XP and Android. I'm not fully sure but I think that someone described how to burn the image to a physical EPROM or whatever hardware, to use the JPC ROM in a physical HP-71B. Perhaps you'd want to try. For the record, I used the amazing JPC ROM functionalities to help me solve about 100 Project Euler problems, it was highly entertaining to do that with such old software & hardware ! Best regards. V. . RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Gerson W. Barbosa - 06-03-2019 01:08 PM
(06-03-2019 03:49 AM)Carsen Wrote:(06-01-2019 03:17 PM)Gerson W. Barbosa Wrote: Just two remarks: My mistake, sorry! It didn’t work for me because I picked ->STR from the menu instead of typing in STR->. RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Carsen - 06-03-2019 08:15 PM
(06-03-2019 01:08 PM)Gerson W. Barbosa Wrote:(06-03-2019 03:49 AM)Carsen Wrote: Nice! Save 3 seconds in Exact mode! I sure like that. Lol. Good thing you mentioned OBJ-> though. I somehow forgot OBJ-> parses strings. This must mean I haven't programmed my 50g enough recently RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - Gerson W. Barbosa - 06-04-2019 03:00 AM
(06-01-2019 03:07 AM)Gerson W. Barbosa Wrote: Optionally, write a program that does the same for primes greater than 2 in base 8. In this case, the last digits are 1, 3, 5 and 7. Ok, that’s trivial from any of the base-10 programs. Anyway, for the sake of completeness, here is a 34-step program for the wp34s based on Dave Britten’s base-10 program for the DM42/HP-42S: Code:
1000 A -> 253 R↓ -> 254 R↓ -> 252 R↓ -> 241, that is, 241 1’s, 252 3’s, 254 5’s and 253 7’s. Running time in tenths of seconds in register 02: RCL 02 -> 730 (low-battery condition) or RCL 02 -> 469 (USB-powered) RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - fred_76 - 06-04-2019 02:21 PM
Some interesting paper to understand the countings: https://dms.umontreal.ca/~andrew/PDF/PrimeRace.pdf RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g) - ttw - 06-04-2019 05:09 PM
Adding to Fred's suggested paper (which is really worth reading) is this Guy's paper. https://www.ime.usp.br/~rbrito/docs/2322249.pdf One of the examples: D. H. & Emma Lehmer discovered that 2^n=3 (mod n) for n = 4700063497, but for no smaller n > 1. |