Namma Suvarna Karnataka
SCJP SCWCD
Namma Suvarna Karnataka
Originally posted by Jon Pincott:
I get one solution:
Area of triangle with sides (27246963, 27246964, 27246965) = 321467351292366
You can't use Heron's formula directly as the products don't fit into a long, but the initial conditions allow you to simplify and find a neccessary and sufficient condition to test as follows:
P.S. if anyone has got a neater way to test if a number is a square (without precomputing a list of squares in the range) then please post it.
Originally posted by John Smith:
<b>JP: Math.sqrt(3L*(b+2)*(b-2)) * b/4</b>
Can you explain how you reduced Heron's formula to this?
Namma Suvarna Karnataka
Namma Suvarna Karnataka
SCJP SCWCD
SCJP SCWCD
Namma Suvarna Karnataka
Originally posted by Arjunkumar Shastry:
{
1) Loop over (int) b from 10000001 to 99999998 to cover all 8-digit triples.
2) For each b, test whether 3(b+2)(b-2) is a square. (from eq(2))
}
Looping can be reduced to half as b will always be even integer.i.e. a will alway be odd integer as shown above in your result.
Namma Suvarna Karnataka
Don't get me started about those stupid light bulbs. |