Java Program Fibonacci Sequence

前端 未结 15 1876
被撕碎了的回忆
被撕碎了的回忆 2020-12-17 03:17

I am writing a \"simple\" program to determine the Nth number in the Fibonacci sequence. Ex: the 7th number in the sequence is: 13. I have finished writing the program, it

15条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-17 03:51

    The problem is not JAVA, but the way you are implementing your Fibonacci algorithm. You are computing the same values many times, which is slowing your program.

    Try something like this : Fibonacci with memoization

提交回复
热议问题