Euler's sum of powers conjecture: Difference between revisions

Content added Content deleted
(→‎{{header|QL SuperBASIC}}: outline changes for ZX80)
Line 3,397: Line 3,397:


=={{header|QL SuperBASIC}}==
=={{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 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) and 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.


<lang qbasic>
<lang qbasic>
1 CLS
1 CLS
2 DIM i%(255,6) : DIM n%(6) : DIM a%(6)
2 DIM i%(255,6) : DIM a%(6) : DIM u%(6)
3 DIM v%(255,6) : DIM u%(6) : DIM b%(6) : DIM d%(29)
3 DIM v%(255,6) : DIM b%(6) : DIM d%(29)
4 RESTORE 137
4 RESTORE 137
6 FOR m=0 TO 6
6 FOR m=0 TO 6
7 READ t% : n%(m)=t%
7 READ t%
8 FOR j=1 TO 255
8 FOR j=1 TO 255
11 LET i%(j,m)=j MOD t%
11 LET i%(j,m)=j MOD t%