Advertisement
allia

номер числа Фибоначчи

Sep 10th, 2020
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.   long long res1=1, res2=1, a=0;
  8.   cin >> a;
  9.   int arr[46];
  10.   if (a==0)
  11.   cout << 1;
  12.   else for (int i=4; i<47; i++)
  13.   {
  14.     res2+=res1;
  15.     res1=res2-res1;
  16.      if (a==res2)
  17.     {
  18.       res1 = i;
  19.       cout << res1;
  20.       break;
  21.     }
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement