Choosing right trimmer and capacitor in LM317 circuit
For CADJ use an electrolytic capacitor of 4.7 to 22 microfarads (TI used 10 microfarads for testing electrical characteristics of LM317).

Check Figure 3 / page 8 in the datasheet.

Here is how to connect the potentiometer:







simulate this circuit &ndash; Schematic created using CircuitLab

By the way, you can use a 3.9 kiloohms resistor instead of potentiometer or trimmer. You'll get almost 22 V.