I think you miss initial value of n variable ....