Answer:
20.6 feet
Explanation:
The Pythagorean theorem can tell you the distance from the house the base of the ladder may be for it to reach 40 feet up. If that distance is represented by x, then it tells you ...
45^2 = x^2 + 40^2
x = √(2025 -1600) = √425
x ≈ 20.6
The ladder will reach to 40 feet high when the base is 20.6 feet from the house.
_____
Comment on ladder distance
The ladder safety association recommends an angle with the ground of about 75°. That corresponds to a distance from the house of about 10 feet. If the ladder is 20 feet away, it will barely reach the gutter, so placing it at that distance would probably not be safe.
An appropriate answer to this question is "10 feet", not based on math, but based on safety. At that distance the end of the ladder will extend about 3.7 feet beyond the gutter.