deyanivanov966

04. Even Powers of 2

Oct 2nd, 2020 (edited)
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class demo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.  
  8.         //за всяка една степен от 0 до n
  9.         //повтаряме: принтираме 2 на степен
  10.         //увеличаваме с 2
  11.  
  12.  
  13.         for (int step = 0; step <= n ; step += 2) {
  14.             System.out.printf("%.0f%n", Math.pow(2, step));
  15.         }
  16.     }
  17. }
Add Comment
Please, Sign In to add comment