Euler's sum of powers conjecture: Difference between revisions
Content added Content deleted
m (→ES5: fixed error that was only in output) |
(→{{header|ZX Spectrum Basic}}: completed "slide rule" fix) |
||
Line 3,945: | 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 |
{{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 |
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 the square root, will still lose precision and find false solutions, as a difference of 2 in one of the summands results in a difference in just the 11th place after the decimal point. 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. |
Very, very, very slow. Even with an emulator at full speed. |
||
<lang zxbasic> |
<lang zxbasic> |
||
2 DIM p(249): DIM q(249) |
2 DIM p(249): DIM q(249) |
||
4 FOR i=1 TO 249 |
4 FOR i=1 TO 249: q(i)=5*LN i: p(i)=q(i)/2: NEXT i |
||
⚫ | |||
5 q(i)=LN i |
|||
⚫ | |||
6 NEXT i |
|||
35 LET lnsum=LN sum |
|||
45 FOR m=8 TO 249 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
55 IF lnsum>p(m) THEN NEXT m |
|||
⚫ | |||
60 NEXT z: NEXT y: NEXT x: NEXT w |
60 NEXT z: NEXT y: NEXT x: NEXT w |
||
</lang> |