import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int length = 20;
long[] series = new long[length];
series[0] = 0;
series[1] = 1;
for (int i = 2; i < length; i++) {
series[i] = series[i - 1] + series[i - 2];
}
System.out.print(Arrays.toString(series));
}
}
The output:
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181]
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |