Determine all possible triplet(s) (a, b, c) of positive integers, with a ≤ b ≤ c, that satisfy this equation.
a*b+b*c+c*a - (a+b+c) = 21
DEFDBL A-Z
FOR a = 1 TO 1000
FOR b = a TO 1000
FOR c = b TO 1000
IF a * b + b * c + c * a - (a + b + c) = 21 THEN PRINT a; b; c
NEXT
NEXT
NEXT
finds
1 1 22
1 2 11
2 2 7
2 3 5
Overkill because lowest difference for given max number (c) should be when a and b are each 1. Then if
1+ c+c - (1+1+c) > 21
c > 22
and vice versa so we shouldn't expect any of the numbers to be greater than 22.
|
Posted by Charlie
on 2010-06-07 13:19:11 |