/**
* Fibonacci progression.
* F(0) = 0;
* F(1) = 1;
* F(i) = F(i-1) + F(i-2) for each i greater than 1
*/
class FibonacciProgression extends Progression {
long prev; F(i-1)
// Inherits variables first and cur. In this case, cur also represents F(i)
/** Default constructor. */
FibonacciProgression() {
prev = 0;
first = 1;
}
/** Advances the progression by adding the previous value to the current value.
*
* @return next value of the progression
*/
protected long nextValue() {
long temp = prev;
prev = cur;
cur += temp;
return cur;
}
// Inherits methods firstValue() and printProgression(int).
}