Solve problem "The index of a Fibonacci number" online - Learn Python 3 - Snakify

Problem «The index of a Fibonacci number» (Hard)


Statement

The Fibonacci sequence is defined as follows: $$ \phi_0 = 0, \ \phi_1 = 1, \ \phi_n = \phi_{n-1} + \phi_{n-2} . $$ Given an integer \( a \), determine its index among the Fibonacci numbers, that is, print the number \( n \) such that \( \phi_n = a \). If \( a \) is not a Fibonacci number, print -1.

In all the problems input the data using input() and print the result using print().



Saved solutions

Tests

Input Correct answer Result
8
6
10
-1
13
7
55
10
56
-1
57
-1
54
-1
2
3
3
4
4
-1
5
5
6
-1
1134903170
45
1134903171
-1
1134903169
-1