public class Main {
public static void main(String[] args) throws IOException {
LongStream fib = LongStream.generate(new FibSupplier());
// 打印Fibonacci数列:1,1,2,3,5,8,13,21...
fib.limit(10).forEach(System.out::println);
}
}
class FibSupplier implements LongSupplier {
int f = 0;
int s = 1;
boolean flag = true;
public long getAsLong() {
int c = f + s;
f = s;
s = c;
return f;
}
}
shadowTy