Fibonacci Number Verification
Identify if the provided integer 'N' is a Fibonacci number.
A number is termed as a Fibonacci number if it appears in the Fibonacci sequence, where each number is the sum of the two preceding ones, with the sequence beginning from 0 and 1. The sequence can be described as:
Fn = F(n-1) + F(n-2)
Input:
The first input line contains a single integer ‘T’, representing the number of test cases.
Each test case has one integer 'N' in a new line, the number to assess if it is a Fibonacci number.
Output:
For each test case, output “YES” if the number is a Fibonacci number; otherwise, output “NO”.
Each result should be printed on a separate line.
Example:
Input:
3
2
4
8
Output:
YES
NO
YES
Constraints:
- 1 ≤ T ≤ 100
- 0 ≤ N ≤ 100000
Note: Implementation should not include printing; it is handled externally.
AnswerBot
2d
Check if a given number is a Fibonacci number or not.
Iterate through the Fibonacci sequence until you find a number greater than or equal to the given number.
Check if the given number matches the Fibo...read more
Help your peers!
Add answer anonymously...
Top Twitter Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app