[VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
04-28-2019, 11:08 AM (This post was last modified: 07-23-2019 01:10 PM by Albert Chan.)
Post: #47
 Albert Chan Senior Member Posts: 684 Joined: Jul 2018
RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
Hi, rprosperi

Thanks for the tip. I finally get FPRIM working, but had to switched to EMU71/DOS
This is my updated HP71B BASIC listing.

Quote:10 ON ERROR GOTO 190
20 INPUT "BASE?";B
30 N=CEIL(12/LOG10(B)) @ DIM S(N),L(N),H(N)
40 FOR C=4 TO (B-1)*N
50 IF GCD(C,B-1)=1 AND FPRIM(C,C)=0 THEN
60 T=0 @ I=N @ S(I)=C @ GOSUB 100 @ PRINT C;T
70 END IF
80 NEXT C
90 END

100 L(I)=MAX(S(I)-(B-1)*(I-1), 0)
110 H(I)=MIN(S(I), B-1)
120 IF L(I)>H(I) OR T THEN RETURN
130 IF I=1 THEN GOTO 170
140 S(I-1)=S(I)-L(I)
150 I=I-1 @ GOSUB 100 @ I=I+1
160 L(I)=L(I)+1 @ GOTO 120

170 FOR K=N TO 1 STEP -1 @ T=T*B+L(K) @ NEXT K
180 T=FPRIM(T,T) @ RETURN
190 T=-T @ RETURN

>RUN
BASE? 7
25 4801
35 201683
49 16470859
55 115296019
65 1971561941
77 96848656799
85 -1.3564461457E12

>RUN
BASE? 31
49 619
77 18257
91 59581
119 1787459
121 2769601
133 13851853
143 22164503
161 372178931
169 629810569
187 7987533097
203 23073248663
209 54109095389
217 247613526037
221 357635354291
247 -6.82312829953E12
253 -1.19404745241E13
259 -1.70578207488E13

Ignore lines with negative numbers. It just meant T (for the sb value) overflow 12 digits.

Note: It is possible primes not in sorted order. Example:
>RUN
BASE? 2
4 23
6 311
8 383
...
36 206141652991
38 -1.01361228185E12 <- actual T = 1030791102463
39 824633720831
40 -1.09951162777E12 <- actual T = 2196875771903
 « Next Oldest | Next Newest »

 Messages In This Thread [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 03-21-2019, 02:08 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 03-21-2019, 12:21 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Paul Dale - 03-21-2019, 12:30 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - J-F Garnier - 03-22-2019, 08:04 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 03-23-2019, 12:40 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - J-F Garnier - 03-23-2019, 07:53 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - rprosperi - 03-23-2019, 09:49 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 03-23-2019, 04:03 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - J-F Garnier - 03-24-2019, 09:08 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Oulan - 03-25-2019, 09:19 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Oulan - 03-25-2019, 04:27 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Gerson W. Barbosa - 03-25-2019, 09:01 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 03-25-2019, 09:53 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 03-28-2019, 12:38 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Werner - 03-28-2019, 11:10 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Gilles - 04-26-2019, 11:36 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 03-28-2019, 12:51 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 03-29-2019, 01:55 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Juan14 - 03-31-2019, 02:51 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 03-31-2019, 03:26 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 03-31-2019, 10:11 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Juan14 - 04-01-2019, 12:49 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-01-2019, 03:25 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - J-F Garnier - 04-01-2019, 04:42 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 04-02-2019, 10:43 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-03-2019, 02:05 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-03-2019, 02:57 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 04-05-2019, 01:58 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-05-2019, 07:40 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - John Keith - 04-07-2019, 04:58 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Gerson W. Barbosa - 04-09-2019, 06:53 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 04-09-2019, 11:37 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - John Keith - 04-10-2019, 04:11 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-08-2019, 03:36 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Bernd Grubert - 04-13-2019, 08:01 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-13-2019, 10:35 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Valentin Albillo - 04-13-2019, 11:27 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Bernd Grubert - 04-14-2019, 04:39 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - John Keith - 04-14-2019, 07:57 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Bernd Grubert - 04-20-2019, 10:47 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Gilles - 04-21-2019, 07:06 AM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-24-2019, 08:30 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-26-2019, 06:13 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - rprosperi - 04-26-2019, 09:50 PM RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - Albert Chan - 04-28-2019 11:08 AM

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