1. "Trial and error" solution (by guessing) is 4 meters (width) and 10 meters (length) and takes 4 seconds.
2. Algebra solution is via this equation
x*(x+6) = 40
x^2 + 6x - 40 = 0
(x+10)*(x-4) = 0
giving the same answer x= 4 meters for the width and (x+6) = (4+6) = 10 meters for the length.