Powers of two

Report a typo

Implement a method that returns a prepared stream of the first n powers of two starting from the 0th power, that is, your output should start with 1.

Sample Input 1:

3

Sample Output 1:

1 2 4
Write a program in Java 17
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class StreamUtils {

public static Stream<Integer> generateStreamWithPowersOfTwo(int n) {
return Stream.empty(); // replace it with your code
}
}
___

Create a free account to access the full topic