myrdok123

04. Even Powers of 2

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