Please see the comment on code below to see the problem.
<html>
<head>
<title>Sequence: x ^ n -1</title>
</head>
<body>
<script type = "text/javascript">
var sqn;
var pow=1;
var pans=1;
do {
sqn = prompt("Enter Sequence: ");
}while(sqn<0);
var psqn;
psqn=parseFloat(sqn);
if (psqn==0){
document.write("0");
}
else if (psqn>0){
document.write("9<font color=red> --- </font>");
for (x=1;x<psqn;x++){
pans=1;
for (y=0;y<=pow;y++){
pans = pans*10;
}
--pans;//this line does not work when user input is greater than 15
pow++;
document.write(pans + "<font color=red> --- </font>");
}
}
</script>
</body>
</html>