Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public static void FibonacciGoldenNuggets()
  2. {
  3. BigInteger PolynomialApproximation(BigInteger p, BigInteger q)
  4. {
  5. var pq = p * q;
  6. var denom = q * q - pq - p * p;
  7.  
  8. return (pq % denom != 0) ? -1 : pq / denom;
  9. }
  10. FibonacciNumbers()
  11. .Skip(2)
  12. .Where((x, i) => i % 2 == 0)
  13. .Zip(FibonacciNumbers().Skip(2).Where((x, i) => i % 2 == 1), (x, y) => (x, y))
  14. .Select(t => PolynomialApproximation(t.x, t.y))
  15. .DisplayStreamForce(stop: true);
  16. }
  17.  
  18. public static IEnumerable<BigInteger> FibonacciNumbers(int firstSeed = 0, int secondSeed = 1)
  19. {
  20. for (BigInteger first = firstSeed, second = secondSeed; ; first += second, second += first)
  21. {
  22. yield return first;
  23. yield return second;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement