galinyotsev123

ProgBasics05while-Loop-P08sequence2kPlus1

Jan 7th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P08sequence2kPlus1 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int n = Integer.parseInt(scanner.nextLine());
  7. int x = 1;
  8. while (x <= n) {
  9. System.out.println(x);
  10. x = x * 2 + 1;
  11. }
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment