Advertisement
Guest User

04. Even Powers of 2

a guest
Feb 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class p04 {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int n = Integer.parseInt(console.nextLine());
  7.         int currNum = 1;
  8.         double power2 = Math.pow(2, n);
  9.         while (currNum <= power2 ){
  10.             System.out.println(currNum);
  11.             currNum *= 4;
  12.         }
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement