User talk:Retroburrowers

Revision as of 15:08, 30 April 2020 by Frisian (talk | contribs) (added a missing /)

A little info why your programs did not give results.

<lang zxbasic> 5 FOR r=34 TO 5 STEP -1 10 FOR m=r TO 249 STEP 30 20 FOR w=4 TO (m-1):FOR x=3 TO (w-1):FOR y=2 TO (x-1):FOR z=1 TO (y-1) 30 LET sum=INT(w^4/m*w + x^4/m*x + y^4/m*y + z^4/m*z + 0.5) 40 LET s1=m^4 45 IF sum>s1 THEN GO TO 65 50 IF s1=sum THEN PRINT w;"^5+";x;"^5+";y;"^5+";z;"^5=";m;"^5": STOP 60 NEXT z: NEXT y: NEXT x: NEXT w 65 NEXT m: NEXT r</lang>

<lang zxbasic> 2 DIM p(249) : DIM q(249)

4 FOR i=1 TO 249 
5  LET p(i)=i*i : LET q(i)=p(i)*i
6 NEXT i
8 FOR r=34 TO 5 STEP -1

10 FOR m=r TO 249 STEP 30 20 FOR w=4 TO (m-1): FOR x=3 TO (w-1): FOR y=2 TO (x-1): FOR z=1 TO (y-1) 30 LET sum=INT(q(w)/q(m)*p(w) + q(x)/q(m)*p(x) + q(y)/q(m)*p(y) + q(z)/q(m)*p(z) +0.5) 40 LET s1=p(m) 45 IF sum>s1 THEN GO TO 65 50 IF s1=sum THEN PRINT w;"^5+";x;"^5+";y;"^5+";z;"^5=";m;"^5": STOP 60 NEXT z: NEXT y: NEXT x: NEXT w 65 NEXT m: NEXT r<lang>

<lang zxbasic> 2 DIM p(249) : DIM q(249)

4 FOR i=1 TO 249 
5  LET q(i)=LN i
6 NEXT i
8 FOR r=34 TO 5 STEP -1

10 FOR m=r TO 249 STEP 30 20 FOR w=4 TO (m-1): FOR x=3 TO (w-1): FOR y=2 TO (x-1): FOR z=1 TO (y-1) 30 LET sum=EXP(q(w)-q(m)) + EXP(q(x)-q(m)) + EXP(q(y)-q(m)) + EXP(q(z)-q(m)) 35 IF sum>1 THEN GO TO 65 50 IF sum=1 THEN PRINT w;"^5+";x;"^5+";y;"^5+";z;"^5=";m;"^5": STOP 60 NEXT z: NEXT y: NEXT x: NEXT w 65 NEXT m: NEXT r</lang>

All these versions have 1 fatal flaw. When sum it greater then a certain value they jump to NEXT m instead they should jump to NEXT y.

Let's say that m = 10 and

 w     x     y     z
8^5 + 7^5 + 6^5 + 5^5 = 32768 + 16807 + 7776 + 3125 = 60476 
9^5 + 3^5 + 2^5 + 1^5 = 59049 +   243 +   32 +    1 = 59325

To demonstrate this let's take version and alter it a little bit in order to give a fast result.
We set m to 144, w to 133 ,x to 110, and y = 70 to speed things up.
<lang zxbasic> 2 DIM p(249) : DIM q(249)
4 FOR i=1 TO 249 
5 LET p(i)=i*i : LET q(i)=p(i)*i
6 NEXT i

10 FOR m=144 TO 144 STEP 30 : let s1=p(m) 20 FOR w=133 TO (m-1): FOR x=110 TO (w-1): FOR y=70 TO (x-1): FOR z=1 TO (y-1) 30 LET sum=INT(q(w)/q(m)*p(w) + q(x)/q(m)*p(x) + q(y)/q(m)*p(y) + q(z)/q(m)*p(z) +0.5) 45 IF sum>s1 THEN GO TO 65 50 IF s1=sum THEN PRINT w;"^5+";x;"^5+";y;"^5+";z;"^5=";m;"^5": STOP 60 NEXT z 61 NEXT y: NEXT x: NEXT w 65 NEXT m: </lang>

Run it and simple stops with out a result, since m does not increase we can check the value of y and z, y = 74, z = 73. In line 45 change <lang zxbasic>GO TO 65</lang> to <lang zxbasic>GO TO 61</lang>. Rerun it and after a while it will produce the correct answer 133^5+110^5+84^5+27^5=144^5.

Please remember that the ZX Spectrum is 38 years old and it was not designed for this kind of tasks, it was a cheap and simple computer.

Return to the user page of "Retroburrowers".