Post Reply 
[VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
04-26-2019, 06:13 PM (This post was last modified: 04-27-2019 12:25 AM by Albert Chan.)
Post: #44
RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
I did downloaded the Emu71/Windows, but unable to get the code fully worked out.

HP-71B BASIC code below only print out possible sb candidates.
The program cannot be completed without ISPRIME(), so I never posted it.

What it does is output values of permutations of base-B digits that have the inputed sb value.

Quote:10 INPUT "BASE ?"; B
20 INPUT "DIGITS ?"; N
30 DIM S(N),L(N),H(N)
40 INPUT "SB VALUE ?"; S(N)
50 I = N
60 GOSUB 100
70 END

100 L(I) = S(I)-(B-1)*(I-1)
110 IF L(I) < 0 THEN L(I) = 0
120 H(I) = S(I)
130 IF H(I) >= B THEN H(I) = B-1

150 IF L(I) > H(I) THEN RETURN
160 IF I = 1 THEN GOTO 200
170 S(I-1) = S(I)-L(I)
180 I = I-1 @ GOSUB 100 @ I = I+1
190 L(I) = L(I)+1 @ GOTO 150

200 T = 0
210 FOR K = N TO 1 STEP -1
220 T = T*B+L(K)
230 NEXT K
240 PRINT T;

250 INPUT "MORE?";Y
260 IF Y<>0 THEN RETURN

Example: for base-7, upto 12 decimal digits => 15 base-7 digits

>RUN
>BASE ? 7
>DIGITS ? 15
>SB VALUE ? 65

1694851493 → 1936973135 → 1971561941 (first prime)

>RUN
>BASE ? 7
>DIGITS ? 15
>SB VALUE ? 77

83047723205 → 94911683663 → 96606535157 → 96848656799 (first prime)

BTW, where to get ISPRIME() (or equivalent) for the HP-71B emulator ?

Edit: change PRINT "X?" @ INPUT X to INPUT "X?";X
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-26-2019 06:13 PM



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