-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx7.java
More file actions
28 lines (22 loc) · 763 Bytes
/
Ex7.java
File metadata and controls
28 lines (22 loc) · 763 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
package java_exercises_1_sda;
//Napisz funkcję tworzącą ciąg arytmetyczny o podanych: długości, pierwszym elemencie,
// różnicy ciągu
public class Ex7 {
public static void main(String[] args) {
int[] result = arraySeries(4, 1, 2);
Ex6.tablePrint(result);
}
public static int[] arraySeries(int lenght, int firstNumber, int gap) {
int[] array = new int[lenght];
array[0] = firstNumber;
for (int i = 1; i < lenght; i++) {
array[i] = array[i - 1] + gap;
}
return array;
}
}
// public static void tablePrint(int[] array) {
// for (int index : array) {
// System.out.println("[" + index + "] ");
// }
// System.out.println("");