martinvalchev

Even Powers of 2

Nov 21st, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.33 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EvenPowersof2 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         for (int i = 0; i <= n ; i+= 2) {
  10.             System.out.println((int)Math.pow(2, i));
  11.  
  12.  
  13.         }
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment