Easy. It's because you assign n to itself before you increment it. The expected way would be simply

n++;

instead of

n = n++;

To give you the output of

1
2
3
4
5