your configuration is for constant current, the maximum current you can draw at 15V difference between Vin & Vout is 2.2A as per datasheet.
since the voltage drop will be very less here, it will work comfortably. calculate the resistance value for 1500 mA or little less. R=1.2/I (may vary litle).
if you see the package getting hot you can provide adiquate heat sink for more discipation.
The typical dropout voltage of an LM317 at 1.5A is 2.25V but could be more.
The 0.8 ohm resistor needs 1.25V.
So with a 40.0V supply the LEDs can be no more than 36.5V.
The LM317 will get very hot. Prepare to use a heat sink. The resistor will also get hot, since it is dissipating 1.0 Watts. It should be rated at 2W if it is to be reliable.