Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,18 @@
import java.util.function.LongUnaryOperator;
import java.util.stream.LongStream;
public class FibUtil {
public static LongStream fibStream() {
return LongStream.iterate( 1l, new LongUnaryOperator() {
private long lastFib = 0;
@Override public long applyAsLong( long operand ) {
long ret = operand + lastFib;
lastFib = operand;
return ret;
}
});
}
public static long fib(long n) {
return fibStream().limit( n ).reduce((prev, last) -> last).getAsLong();
}
}