Please see the comment on code below to see the problem.

		<title>Sequence: x ^ n -1</title>
		<script type = "text/javascript">
		var sqn;
		var pow=1;
		var pans=1;
		do {
			sqn = prompt("Enter Sequence: ");
		var psqn;
		if (psqn==0){
		else if (psqn>0){
			document.write("9<font color=red> --- </font>");
			for (x=1;x<psqn;x++){
				for (y=0;y<=pow;y++){
					pans = pans*10;
				--pans;//this line does not work when user input is greater than 15
				document.write(pans + "<font color=red> --- </font>");

line 21 - You put pans at 1 every time the loop is repeated.


commented: sorry, not helpful. +0

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.

That is an expected result. On most 32-bit platforms the largest javascript integer is 2^31-1 and the maximum precision of a floating point number is 15 digits.