Post Reply 
RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
06-04-2019, 03:00 AM (This post was last modified: 06-04-2019 03:05 AM by Gerson W. Barbosa.)
Post: #28
RE: RPL exercise - Last Digits of Primes (HP 49G, G+, 50g)
(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. 

  40 --> {7 12 11 10}

 120 --> {27 33 30 30}

1000 --> ?

  

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:

001 LBL A
002 STO A
003 CLx
004 FILL
005 STOS 01
006 STOS 05
007 # 001
008 TICKS
009 STO 02
010 LBL 00
011 R↓
012 INC X
013 INC X
014 PRIME?
015 XEQ 01
016 RCL 04
017 x<? A
018 GTO 00
019 TICKS
020 RCL- 02
021 STO 02
022 RCL 01
023 RCL 03
024 RCL 05
025 RCL 07
026 RTN
027 LBL 01
028 INC 04
029 RCL X
030 # 008
031 MOD
032 INC→X
033 R↓
034 END

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)
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-04-2019 03:00 AM



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