Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void FibonacciGoldenNuggets()
- {
- BigInteger PolynomialApproximation(BigInteger p, BigInteger q)
- {
- var pq = p * q;
- var denom = q * q - pq - p * p;
- return (pq % denom != 0) ? -1 : pq / denom;
- }
- FibonacciNumbers()
- .Skip(2)
- .Where((x, i) => i % 2 == 0)
- .Zip(FibonacciNumbers().Skip(2).Where((x, i) => i % 2 == 1), (x, y) => (x, y))
- .Select(t => PolynomialApproximation(t.x, t.y))
- .DisplayStreamForce(stop: true);
- }
- public static IEnumerable<BigInteger> FibonacciNumbers(int firstSeed = 0, int secondSeed = 1)
- {
- for (BigInteger first = firstSeed, second = secondSeed; ; first += second, second += first)
- {
- yield return first;
- yield return second;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement