Advertisement
SvetlanPetrova

Sequence 2k + 1 SoftUni

Apr 27th, 2021
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Sequence2k1 {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scanner = new Scanner(System.in);
  7.         int inputNum = Integer.parseInt(scanner.nextLine());
  8.  
  9.         int result = 1;
  10.  
  11.         while (result <= inputNum) {
  12. //            int currentNum = Integer.parseInt(scanner.nextLine());
  13.             System.out.println(result);
  14.             result = result * 2 + 1;
  15.         }
  16.     }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement