Jump to content

Euler's sum of powers conjecture: Difference between revisions

→‎{{header|ZX Spectrum Basic}}: completed "slide rule" fix
m (→‎ES5: fixed error that was only in output)
(→‎{{header|ZX Spectrum Basic}}: completed "slide rule" fix)
Line 3,945:
 
{{Incorrect|ZX Spectrum Basic|ZX Spectrum Basic has one numerical type, floating point consisting of 5 bytes, of which one holds the exponent, leaving 4 for the
mantissa. 249^4 is not too big to fit in those 4 bytes, but even 215^4 fills up all available bits. Adding up logarithmic "percentages" by subtracting that of the target sum from that of each summand and seeing if the inverses add up to onethe square root, will still lose precision and find false solutions, evenas if separating the integer part of q into p, asa difference of 2 in one of the summands results in a difference in just the 11th place after the decimal placepoint. Even QL SuperBASIC can only make such FP comparisons down to the 7th. But the attempted fix should only be very slow.}}
Very, very, very slow. Even with an emulator at full speed.
 
<lang zxbasic>
2 DIM p(249): DIM q(249)
4 FOR i=1 TO 249: q(i)=5*LN i: p(i)=q(i)/2: NEXT i
20 FOR w=7 TO (m-1)245 STEP 7: FOR x=5 TO (m-3)245 STEP 5: FOR y=3 TO (m-5)246 STEP 3: FOR z=2 TO (m-6)248 STEP 2
5 q(i)=LN i
30 LET sum=EXP((q(w)-qp(m))*5)+ EXP((q(x)-qp(m))*5) + EXP((q(y)-qp(m))*5) + EXP((q(z)-qp(m))*5)
6 NEXT i
35 LET lnsum=LN sum
1045 FOR m=8 TO 249
20 FOR w=7 TO (m-1)STEP 7: FOR x=5 TO (m-3)STEP 5: FOR y=3 TO (m-5)STEP 3: FOR z=2 TO (m-6)STEP 2
50 IF sumlnsum=1p(m) THEN PRINT w;"^5+";x;"^5+";y;"^5+";z;"^5=";m;"^5": STOP
30 LET sum=EXP((q(w)-q(m))*5)+ EXP((q(x)-q(m))*5) + EXP((q(y)-q(m))*5) + EXP((q(z)-q(m))*5)
3555 IF sumlnsum>1p(m) THEN GO TONEXT 65m
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</lang>f
Cookies help us deliver our services. By using our services, you agree to our use of cookies.