Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EvenPowersOf2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //степени: 0 до n
- //повтаряме: печатаме 2 на дадената степен
- //начална стойност: 0
- //крайна стойност: n
- //променяме: увеличаваме с 2
- int n = Integer.parseInt(scanner.nextLine());
- for (int power = 0; power <= n; power += 2) {
- System.out.printf("%.0f%n", Math.pow(2, power));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment