I am doing a project, in which I have to realise a differential equation in discrete time, i.e. finite difference equation.

I basically need to implement this kind of equation :

y(n) + y(n-1) = x(n) + x(n-2)

x(n) are analogRead values, acting as variables to the equation, whose output is y(n).

I have to use arrays, but I'm finding it difficult to code.

Please help. Thanks