#K2046. Fibonacci Number Verification
Fibonacci Number Verification
Fibonacci Number Verification
Given an integer n, determine whether it is a Fibonacci number or not. A number is a Fibonacci number if it appears in the Fibonacci sequence. An interesting property is that a number n is a Fibonacci number if and only if at least one of
$$5n^2 + 4$$
or
$$5n^2 - 4$$
is a perfect square. Your task is to implement a function which, for each test case, checks this condition and prints YES
if n is a Fibonacci number, and NO
otherwise.
inputFormat
The first line of input contains an integer T
, indicating the number of test cases.
Each of the following T
lines contains a single integer n
.
outputFormat
For each test case, output a single line containing YES
if n
is a Fibonacci number, or NO
otherwise.
5
0
1
2
4
123456789012345678
YES
YES
YES
NO
NO
</p>