We have been given an array and our task is to check if the element of array is present in Fibonacci series or not. If yes, then print that element.
Input : 4, 2, 8, 5, 20, 1, 40, 13, 23 Output : 2 8 5 1 13 Here, Fibonacci series will be 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. Numbers that are present in array are 2, 8, 5, 1, 13 For 2 -> 5 * 2 * 2 - 4 = 36 36 is a perfect square root of 6. Input : 4, 7, 6, 25 Output : No Fibonacci number in this array
A number is said to be in Fibonacci series if either (5 * n * n – 4) or (5 * n * n + 4) is a perfect square. Please refer check if a given number is Fibonacci number for details.
2 8 5 1 13
This article is contributed by Rishabh Jain. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- GCD of elements occurring Fibonacci number of times in an Array
- Array range queries to count the number of Fibonacci numbers with updates
- Array range queries to find the maximum Fibonacci number with updates
- Minimum number of elements to be replaced to make the given array a Fibonacci Sequence
- Check if a M-th fibonacci number divides N-th fibonacci number
- Number of ways to represent a number as sum of k fibonacci numbers
- Finding number of digits in n'th Fibonacci number
- Remove all the fibonacci numbers from the given array
- Nth Even Fibonacci Number
- Nth XOR Fibonacci number
- Find the longest Fibonacci-like subarray of the given array
- Largest and smallest Fibonacci numbers in an Array
- Count of consecutive Fibonacci pairs in the given Array
- Check whether Array represents a Fibonacci Series or not
- Find the next Non-Fibonacci number
- Find the next fibonacci number
- Length of longest subsequence of Fibonacci Numbers in an Array
- Sum and product of K smallest and largest Fibonacci numbers in the array
- How to check if a given number is Fibonacci number?