Это должно решить, я думаю
import math
# A function that returns true if x is perfect square
def isPerfectSquare(x):
s = int(math.sqrt(x))
return s * s == x
# Returns true if n is a Fibinacci Number, else false
def isFibonacci(n):
return isPerfectSquare(5 * n * n + 4) or isPerfectSquare(5 * n * n - 4)
i = [4, 6, 8, 10, 12]
print(i)
j = []
# A utility function to test above functions
for item in i:
if (isFibonacci(item) == True):
j.append(1)
else:
j.append(0)
print(j)
Вывод:
[4, 6, 8, 10, 12]
[0, 0, 1, 0, 0]