1
2
3
4
5
6
7
8
9public
10class Fibonacci extends Sequence {
11 private
12 long x0,x1;
13
14 public
15 Fibonacci() {
16 x0 = 0;
17 x1 = 1;
18 }
19
20 public
21 long next() {
22 long res = x0;
23
24 x0 = x1;
25 x1 = x1 + res;
26
27 return res;
28 }
29}
30
31
32