Determining whether a number is a Fibonacci number

前端 未结 14 1220
暗喜
暗喜 2021-01-18 05:35

I need to to write a Java code that checks whether the user inputed number is in the Fibonacci sequence.

I have no issue writing the Fibonacci sequence to output, b

14条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-18 06:25

    You can do this in two ways , the recursive and mathematical. the recursive way start generating fibonacci sequence until you hit the number or pass it the mathematical way nicely described here ... http://www.physicsforums.com/showthread.php?t=252798

    good luck.

提交回复
热议问题