Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang="en-us">
- <head>
- <meta charset="utf-8">
- <title>Power of Two</title>
- <script>
- /*
- Input: none
- Processing: loops through all powers of two from 0 to 31
- Output: list of power of two from 0 to 31
- */
- function powerTwo() {
- var n = 31;
- var answer = 0;
- var output = "";
- for(var i = 0; i <= n; i ++){
- answer = Math.pow(2,i);
- output += (answer + ", ");
- }
- document.getElementById('output').innerHTML= output;
- }
- </script>
- </head>
- <body onload="powerTwo()">
- <div id="output"></div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment