-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExampleMain.java
More file actions
42 lines (31 loc) · 768 Bytes
/
Copy pathExampleMain.java
File metadata and controls
42 lines (31 loc) · 768 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
30
31
32
33
34
35
36
37
38
39
40
41
42
package examples;
import java.util.ArrayList;
import java.util.List;
/**
* @author TeamworkGuy2
* @since 2014-4-23
*/
public class ExampleMain implements Runnable {
private int num;
public ExampleMain() {
this.num = 20;
}
@Override
public void run() {
List<Integer> list = new ArrayList<Integer>();
series(num, 0, list);
System.out.print(list);
}
private void series(int count, int initial, List<Integer> values) {
int vn1 = values.size() > 0 ? values.get(values.size()-1) : 1;
int vn2 = values.size() > 1 ? values.get(values.size()-2) : 0;
values.add(vn1 + vn2);
if(count > 0) {
series(count-1, initial, values);
}
}
public static void main(String[] args) {
ExampleMain example = new ExampleMain();
example.run();
}
}