Difference equations and their applications