Euler's sum of powers conjecture: Difference between revisions
Content deleted Content added
→{{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.
<lang qbasic>
Line 3,415 ⟶ 3,404:
3 DIM v%(255,6) : DIM u%(6) : DIM b%(6) : DIM d%(29)
4 RESTORE 137
5 LET t%=48▼
8 FOR j=1 TO 255
▲10 FOR m=1 TO 6
▲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
30 FOR w=6 TO 246 STEP 3
33 LET o=w
|