Arrays?

Hey,

I'm doing a project that requires me to calculate a new number from previous numbers. I was thinking of using an array that way I could calculate the new number using something as follows,

setptnew[k] = 2*setptnew[k-1] + 3*setptnew[k-2];

I have to use the two previous numbers calculated to calculate the new one.

Any ideas how I would do this, I can't seem to get it to work.

Any ideas how I would do this

Make sure you don't start until k == 2. Post the rest of your code.

If you only need two previous values you can get away without using an array.

int prevsetpt, prevprevsetpt;

void loop()
    {
    int setpt = 2*prevsetpt + 3*prevprevsetpt;

    prevprevsetpt = prevsetpt;
    prevsetpt = setpt;
    }

However if you are going to be calculating with more than two previous values an array becomes more important.

Thank you Johnwasser it worked perfectly!!