Description


This program uses a "for" loop to calculate all the powers of 2 from 20 to 231, and outputs the entire series.

Input


JavaScript Function



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;
}
	

Output


Dave Irwin @ redirwin.com