asmodeus94

fibRIL

Jan 22nd, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4. int x=6;
  5. long long int liczR;
  6. int fibL(int x){
  7. int a=1,b=1,c,i,licz=0;
  8.     for(i=1;i<=x;i++){
  9.         c=a+b;licz++;
  10.         a=b;licz++;
  11.         b=c;licz++;
  12.     }
  13. return licz;}
  14. long long fibR(int x){
  15.      liczR++;
  16.     if ((x==1)||(x==2)) {liczR++;return 1;} else return fibR(x-1)+fibR(x-2);
  17. }
  18.  
  19. int main(){
  20. cout<<"Literacyjnie: "<<fibL(x)<<endl;  
  21. fibR(x);
  22. cout<<"Rekurencyjnie: "<<liczR<<endl;
  23.  
  24. system("pause>null");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment