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

后端 未结 9 2299
后悔当初
后悔当初 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:41

    You're checking both a and b on every iteration. So that means you're double counting almost everything.

    Edit:

    Ok, I see your update. This is pretty basic debugging, and you should really learn to try it yourself. Think about what the values of a and b are when your loop condition stops being true.

提交回复
热议问题