10 for P=3 to 9999
20 Rp=1//P
30 if 3*Rp<Max then cancel for:goto *Pend
40 for Q=P+1 to 9999
50 Rq=1//Q
60 if Rp+2*Rq<Max then cancel for:goto *Qend
70 for R=Q+1 to 9999
80 Rr=1//R
90 Tot=Rp+Rq+Rr
100 if Tot<Max then cancel for:goto *Rend
110 if Tot<1//2 and (Tot<Max or Max=0) then
120 :Max=Tot:Mp=P:Mq=Q:Mr=R
130 next R
140 *Rend
150 next Q
160 *Qend
170 next P
180
190 *Pend
200 print Mp;Mq;Mr,Max,Max/1
205 print
210 Max=0
220 for P=2 to 99999
230 Rp=1//P
240 if 4*Rp<Max then cancel for:goto *Pend1
250 for Q=P+1 to 99999
260 Rq=1//Q
270 if Rp+3*Rq<Max then cancel for:goto *Qend1
280 for R=Q+1 to 99999
290 Rr=1//R
300 if Rp+Rq+2*Rr<Max then cancel for:goto *Rend1
310 for T=R+1 to 99999
320 Rt=R//T
330 Tot=Rp+Rq+Rr+Rt
340 if Tot<Max then cancel for:goto *Tend1
350 if Tot<1 and (Tot<Max or Max=0) then
360 :Max=Tot:Mp=P:Mq=Q:Mr=R:Mt=T
370 next T
375 *Tend1
380 next R
390 *Rend1
400 next Q
410 *Qend1
420 next P
430
440 *Pend1
450 print Mp;Mq;Mr;Mt,Max,Max/1
finds
p q r t total
3 7 43 451/903 0.4994462901439645625
2 3 7 295 12389/12390 0.9999192897497982243
Edited on November 25, 2012, 12:43 pm
|
Posted by Charlie
on 2012-11-25 12:40:34 |