-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray2.java
More file actions
24 lines (20 loc) · 548 Bytes
/
Array2.java
File metadata and controls
24 lines (20 loc) · 548 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package array;
import java.util.Scanner;
public class Array2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
solution(n);
}
public static void solution(int n) {
int[] arr = new int[n];
int daraja = 1;
for (int i = 0; i < n; i++) {
arr[i] = daraja; // 1 2 4 8 16 32 64 ...
daraja *= 2;
}
for (int i = 0; i < n; i++) {
System.out.print(arr[i] + "\t");
}
}
}