Pythagoras tells you exactly — the ladder is the hypotenuse, the floor gap and the wall height are the two short sides.
Stand a 10-foot ladder with its base 6 feet from the wall. The height it reaches is √(10² − 6²) = √(100 − 36) = √64 = 8 feet. Pull the base out and the reach drops; that's the math behind every 'don't set the ladder too far from the wall' safety rule.