We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4038467 commit 1303ff4Copy full SHA for 1303ff4
Repetition Problems/While Loop/PowerOfTwo.js
@@ -0,0 +1,17 @@
1
+/*
2
+ Write a program that takes a command-line argument n and prints table
3
+ of the powers of 2 that are less than or equal to 2^n till 256 is reached..
4
+*/
5
+
6
+const prompt = require("prompt-sync")();
7
+console.log();
8
+let n = parseInt(prompt(" Enter power : "))
9
+console.log(" Priniting the table of 2 till 2^n or 256 :");
10
+let result;
11
+let i = 1;
12
+while (result != 256 && i <= n) {
13
+ result = Math.pow(2, i);
14
+ console.log(" 2^" + i + ": " + result);
15
+ i++;
16
+}
17
0 commit comments