-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray1B.java
More file actions
29 lines (24 loc) · 630 Bytes
/
Array1B.java
File metadata and controls
29 lines (24 loc) · 630 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
25
26
27
28
29
package array;
import java.util.Scanner;
public class Array1B {
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];
for (int i = 0; i < n; i++) {
// 0 - 1
// 1 - 3
// 2 - 5
// 3 - 7
// 4 - 9
// 5 - 11
arr[i] = i * 2 + 1; // 1 3 5 7 9 11 13 ...
}
for (int i = 0; i < n; i++) {
System.out.print(arr[i] + "\t");
}
}
}