Skip to content

Commit 08667a0

Browse files
committed
feat: Print powers of 2 less than 100 using while loop
🧠 Logic: - Initialize `i = 1`. - Use `while(i < 100)` loop to repeatedly multiply `i` by 2. - Print `i` in each iteration. - Outputs: 1, 2, 4, 8, 16, 32, 64 (powers of 2 < 100). Signed-off-by: Somesh diwan <[email protected]>
1 parent 857ae5d commit 08667a0

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
//While Loop
2-
3-
public class WhileLoopAB
4-
{
5-
public static void main(String[] args)
6-
{
1+
public class WhileLoopAB {
2+
public static void main(String[] args) {
73
int i=1;
8-
while(i<100)
9-
{
4+
while(i<100) {
105
System.out.println(i);
116
i=i*2;
127
}
138
}
14-
}
9+
}

0 commit comments

Comments
 (0)