Advertisement
desislava_topuzakova

04. Even Powers of 2 - second

May 9th, 2020
1,429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement