What is the input - output voltage relationship of an LM317 voltage regulator circuit?
The LM317 will raise or lower the output voltage until the voltage it sees on its Adj pin is the reference voltage (of 1.25 V).

It does that by dynamically adjusting the effective resistance between in- and output. Simply imagine an adjustable resistor between in- and output, and someone tuning that resistor so that the output is always at the same voltage.

It does that within it's physical limits: it can't drop less than 3 V (being a very, very, VERY old regulator), and the more it drops between in and output, the more power it converts to heat (in that resistance mentioned above). 

At some point, the things simply breaks down and can't act as resistor anymore. 40 V (depending on the actual manufacturer of the LM317, that thing is so old, there are multiple masks out there) sounds realistic.