Nonlinear difference equations through variational methods