This program uses a "for" loop to calculate all the powers of 2 from 20 to 231, and outputs the entire series.
function powersOfTwo() { var output = ""; for (var i = 0; i <= 31; i++) { if (i < 31) { output += Math.pow(2, i) + ", "; } else { output += Math.pow(2, i); } } document.getElementById("output").innerHTML = output; }
Dave Irwin @ redirwin.com