DEFDBL A-Z
FOR actot = 2 TO 2000
FOR a = 1 TO actot - 1
c = actot - a
ac = a * c
bd = ac - a - c
absbd = ABS(bd)
SELECT CASE bd
CASE 0
IF a = 1 THEN PRINT a; 0; c; "any neg value"
IF c = 1 THEN PRINT a; "any pos value"; c; 0
CASE IS > 0
FOR d = 1 TO SQR(bd)
b = bd / d
IF b = INT(b) THEN
IF b + d = b * c + a * d THEN
PRINT a; b; c; d
END IF
END IF
NEXT
CASE IS < 0
FOR f1 = 1 TO SQR(absbd)
f2 = absbd / f1
IF f2 = INT(f2) THEN
b = f1: d = -f2
IF b + d = b * c + a * d THEN
PRINT a; b; c; d
END IF
b = f2: d = -f1
IF b + d = b * c + a * d THEN
PRINT a; b; c; d
END IF
END IF
NEXT f1
END SELECT
NEXT
NEXT actot
finds only
1 1 1 -1
as a, b, c and d respectively, where the sum is 2 and the product is 2. (It finds it twice, actually, as in the latter part f1 and f2 are equal.)
All possibilities were searched where a+c totals up to 2000.
Edited on August 29, 2012, 12:56 pm
|
Posted by Charlie
on 2012-08-29 12:54:45 |