A discrete Pinney equation