Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int x=6;
- long long int liczR;
- int fibL(int x){
- int a=1,b=1,c,i,licz=0;
- for(i=1;i<=x;i++){
- c=a+b;licz++;
- a=b;licz++;
- b=c;licz++;
- }
- return licz;}
- long long fibR(int x){
- liczR++;
- if ((x==1)||(x==2)) {liczR++;return 1;} else return fibR(x-1)+fibR(x-2);
- }
- int main(){
- cout<<"Literacyjnie: "<<fibL(x)<<endl;
- fibR(x);
- cout<<"Rekurencyjnie: "<<liczR<<endl;
- system("pause>null");
- }
Advertisement
Add Comment
Please, Sign In to add comment