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