The stack is first in, last out. Suppose you push X, then Y.
(last to come off stack) X Y (first to come off stack).
Make a stack, say s. Before you start your loop, push 1 then 0, or 0 then 0, depending on how the numbers line up.
For each iteration of your loop,
Y = s.pop();
X = s.pop();
s.push(X+Y);
s.push(X);
When you get to N, you simply print s.pop(), assuming it lines up properly.
