Guest User

Untitled

a guest
Jun 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Power of Two</title>
  6. <script>
  7. /*
  8. Input: none
  9. Processing: loops through all powers of two from 0 to 31
  10. Output: list of power of two from 0 to 31
  11. */
  12. function powerTwo() {
  13. var n = 31;
  14. var answer = 0;
  15. var output = "";
  16. for(var i = 0; i <= n; i ++){
  17. answer = Math.pow(2,i);
  18. output += (answer + ", ");
  19. }
  20. document.getElementById('output').innerHTML= output;
  21. }
  22. </script>
  23. </head>
  24. <body onload="powerTwo()">
  25. <div id="output"></div>
  26. </body>
  27. </html>
Add Comment
Please, Sign In to add comment