Advertisement
veronikaaa86

04. Even Powers of 2 (with Math.pow())

Mar 27th, 2021
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. package forLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04EvenPowersOf2 {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int n = Integer.parseInt(scanner.nextLine());
  10.  
  11. for (int i = 0; i <=n; i = i +2) {
  12. System.out.printf("%.0f%n",Math.pow(2, i));
  13. }
  14. }
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement