/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ /** * fib(0) = 0 * fib(1) = 1 * fib(n+2) = fib(n+1) + fib(n) */ //-------------------- public class Fibonacci extends Sequence { private long x0,x1; public Fibonacci() { x0 = 0; x1 = 1; } public long next() { long res = x0; x0 = x1; x1 = x1 + res; return res; } } //--------------------