If A saw 1, she would know that she had 2, and would say so. Therefore,

A did not see 1. A says "I don't know my number."

If B saw 2, she would know that she had 3, since she knows that A did not see

1, so B did not see 1 or 2. B says "I don't know my number."

If A saw 3, she would know that she had 4, since she knows that B did not

see 1 or 2, so A did not see 1, 2 or 3. A says "I don't know my number."

If B saw 4, she would know that she had 5, since she knows that A did not

see 1, 2 or 3, so B did not see 1, 2, 3 or 4. B says "I don't know my number." ... n statements of ignorance later ...

If X saw n, she would know that she had n + 1, since she knows that X did not

see 1 ... n - 1, so X did see n. X says "I know my number."

And the number in n + 1.