Thanks for the effort of posting your VERY helpful answer but I guess that doesn't solve the issue. I intentionally assigned 'pans' to hold a value of '1' every time the loop is repeated to make sure that it will hold a correct value every time a new loop begins.
Additional info: The user inputted value (sqn) determines how many times the equation x^n-1 will be repeated. Example, if user input is 1 then:
10^1 - 1, the program will print "9".
If user input is 3, then:
10^1 - 1, the program loops, 10^2 -1, the program loops for the last time, 10^3-1.
The printed output would be:
9 --- 99 --- 999 ---
the sequence works if user input is !< 0 && <=15. It begins to fail when user input is >=16.