Finding Fibonacci sequence in C#. [Project Euler Exercise]

后端 未结 9 2283
后悔当初
后悔当初 2021-02-06 19:22

I\'m having some trouble with this problem in Project Euler.

Here\'s what the question asks:

Each new term in the Fibonacci sequence is generated by adding t

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-06 19:57

    Here's a nice way to find Fibonnaci numbers.

    IEnumerable Fibs()
    {
        for(BigInteger a = 0,b = 1;;b = a + (a = b))
            yield return b;
    }
    

提交回复
热议问题