Below is an unfinished program that should output all powers of two that are lower than the number entered by the user. Complete the while-loop so that the program will work correctly.
While and do-while loops
Powers of two
Report a typo
Fill in the gaps with the relevant elements
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long num = scanner.nextLong();
result = 1;
( < ) {
System.out.println(result);
result *= 2;
}
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.