Answer :
long leg = x
short leg = x - 8
hypo = 40
x^2 + (x-8)^2 = 40^2
x^2 + x^2 - 16x + 64 = 1600
2x^2 - 16x - 1536 = 0
2(x^2 - 8x - 768) = 0
(x - 32)(x + 24) = 0
x - 32 = 0; x = 32
x + 24= 0;x = -24
so
long leg = 32
short leg = 32 - 8 = 24
short leg = x - 8
hypo = 40
x^2 + (x-8)^2 = 40^2
x^2 + x^2 - 16x + 64 = 1600
2x^2 - 16x - 1536 = 0
2(x^2 - 8x - 768) = 0
(x - 32)(x + 24) = 0
x - 32 = 0; x = 32
x + 24= 0;x = -24
so
long leg = 32
short leg = 32 - 8 = 24