Euler's sum of powers conjecture: Difference between revisions

→‎{{header|QL SuperBASIC}}: outline changes for ZX80
(→‎{{header|QL SuperBASIC}}: outline changes for ZX80)
Line 3,397:
 
=={{header|QL SuperBASIC}}==
This program enhances a modular brute-force search, posted on fidonet in the 1980s, via number theoretic enhancements as used by the program listed under ZX Spectrum Basic, but without the early exit in the control framework so as to be backward-compatible with the lack of floating point in Sinclair ZX80 BASIC (whereby the latter is truly 'zeroeth' generation). To emulate running on a ZX80 (needing a 16K RAM pack & MODifications, some given below) & complete the task sooner than that for the OEM Spectrum, it relies entirely on integer functions, their upper limit being 2^15- 1 in ZX80 BASIC as well. Thus, the "slide rule" calculation of each percentage on the Spectrum is replaced by that of ones' digits across "abaci" of relatively prime bases Pi. Given that each Pi is to be <= 2^7 for said limit's sake, it takes six prime numbers or powers thereof to serve as bases of such a mixed-base number system, since it is necessary that ΠPi > 249^5 for unambiguous representation (as character strings). On ZX80s there are at most 64 consecutive printable characters (in the inverse video block: t%=48 thus becomes T=128). Just seven bases Pi <= 2^6 will be needed, when the difference between 64 & a base is expressible as a four-bit offset, by which one must 'multiply' (since Z80s lack MUL) in the reduction step of the optimal assembly algorithm for MOD Pi. Such bases are: 49, 53, 55, 57, 59, 61, 64. In disproving Euler's conjecture, the program demonstrates that using 60 bits of integer precision in 1966 was 2-fold overkill, or even more so in terms of overhead cost vis-a-vis contemporaneous computers less sophisticated than a CDC 6600.
This program enhances a modular brute-force search posted on fidonet in the 1980s via number theoretical enhancements as used by
the program listed under ZX Spectrum Basic--but without the early exit in the control framework so as to be backward-compatible
with the lack of floating point in Sinclair ZX80 BASIC (whereby the latter is truly 'zeroeth' generation). So that it will run on a
ZX80 (with a 16K RAM pack & some MODification) & complete the task sooner than than that for an unexpanded Spectrum, it relies
entirely on integer functions, their upper limit being 2^15- 1 in ZX80 BASIC as well. Thus, the "slide rule" calculation of each
percentage on the Spectrum is replaced by that of least significant digits across "abaci" of relatively prime bases Pi. Given that
each Pi is to be <= 2^7 for said limit's sake, it will take at least six prime numbers or powers thereof to serve as bases of such
a mixed-base number system, since it is necessary that ΠPi > 249^5 for unambiguous representation. The difference between
successive bases is successive powers of 2, so that one can more easily convert (esp. via assembly, as just shifts & subtractions
will be needed) between base 2^7 & mixed-base representations as character strings. In disproving Euler's conjecture, the program
demonstrates that using 60 bits of integer precision in 1966 was 2-fold overkill, or even more so in terms of overhead cost
vis-a-vis contemporaneous computers less sophisticated than a CDC 6600.
 
<lang qbasic>
Line 3,415 ⟶ 3,404:
3 DIM v%(255,6) : DIM u%(6) : DIM b%(6) : DIM d%(29)
4 RESTORE 137
106 FOR m=10 TO 6
5 LET t%=48
67 FOR m=0 TO 6: READ t% : n%(m)=t%
8 FOR j=1 TO 255
9 11 LET i%(j,0m)=j MOD 30t%
1512 LET v%(j,m)=(vi%(j,m) * i%(j,m))MOD nt%(m)
10 FOR m=1 TO 6
1114 LET iv%(j,m)=(v%(j,m) MOD* nv%(j,m))MOD t%
1215 LET v%(j,m)=(iv%(j,m) * i%(j,m))MOD nt%(m)
17 END FOR mj : END FOR jm
14 LET v%(j,m)=(v%(j,m) * v%(j,m))MOD n%(m)
15 LET v%(j,m)=(v%(j,m) * i%(j,m))MOD n%(m)
17 END FOR m : END FOR j
19 PRINT "Abaci ready"
21 FOR j=10 TO 29: d%(j)=210+ j
24 FOR j=0 TO 9: d%(j)=240+ j
525 LET t%=48
30 FOR w=6 TO 246 STEP 3
33 LET o=w