(In reply to
re(3): an open letter to Charlie by Steve Herman)
Yes, the below program goes much faster, even in interpreted UBASIC, needed because some intermediate results used in solving for a and b exceed the capacity of QB64.
20 ' x = a+b+c
30 for X=0 to 1000000
40 Rhs=X*X*X-X
50
60 if Rhs @ 4 = 0 then
70 :A=-7716049*Rhs//4:B=61728393*Rhs//4
80 :Q=int(abs(A)/30864197)
90 :A=A+Q*30864197:B=B-Q*246913580
100 :while A<0
110 :A=A+30864197:B=B-246913580
120 :wend
130 :while B>=0
140 :C=X-A-B
150 :if C>=0 then print A,B,C
160 :A=A+30864197:B=B-246913580
170 :wend
190 next X
0 0 0
0 0 1
450 4500 5050
7350 6000 6650
27150 1500 1350
About 1 second run time (under 1 second for all the solutins to appear).
The Euclidean algorithm for finding GCD was used to find the constants that multiply by the coefficients to produce the GCD, 4, and zero.
|
Posted by Charlie
on 2013-06-13 18:01:36 |