DMG

N-ti clan Fibonacijevog niza

DMG
Mar 17th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. /* 0 1 1 2 3 5 8 13 21 34 55 89 ... */
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. main ()
  6. {
  7.      int m, n, a[50];
  8.      cin >> n;
  9.      a[0]=0; a[1]=1;
  10.      for (int i=2; i<n; i++)
  11.      {
  12.      a[i]=a[i-1] + a[i-2];
  13.      m = a[i];
  14.      }
  15.      cout << m << endl;
  16.      system ("PAUSE");
  17. }
Advertisement
Add Comment
Please, Sign In to add comment