Fibonacci series

how can we check that number belong to a Fibonacci series or not

@rohanvashist920 Here you need to check if the given number is in the fibonacci series or not.
First few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 141, …
You know that in fibonacci series…0th index number is 0 and 1st index number is 1.
After that, you can get the value at 2nd index as: value at 0th index+ value at 1st index
Similary value at 3rd index is: value at 1st index+ value at second index.

So we can conclude with a formula:

Value at ith index= value at (i-1)th index + value at (i-2)th index. (where i>=2)
So to check if the given number is in the fibonacci series or not run this iteration till condition:
while(value at ith index <= given number )
So if this series ends with the given number, you can say that the number belongs to fibonacci series.
Else you can say that it in not in the fibonacci series.

So try to code on yourself. I have explained the approach.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Hello @rohanvashist920 you have raised the doubt again please tell me how can i help you?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.