Adomas - your code is using n as an index into x. On each iteration of the loop, you increment n by one in preparation for the next iteration. n will be the length of your array x and so will tell you how many iterations have occurred until the tolerance has been satisfied (or until the maximum N has been reached).
As for displaying the data in a table, do you mean your x? Something like
I'm using the ' so that the data is transposed (into a column).