Commit aadd25f8 authored by MUDE CHAITHANYA NAIK's avatar MUDE CHAITHANYA NAIK

Upload new file

parent dfa0e048
#include <iostream>
using namespace std;
double fib(int n){
if (n==0){
return 0;
}
else if (n==1){
return 1;
}
else {
return fib(n-1)+fib(n-2);
}
}
int main(){
int n;
cin>>n;
double a=0,b=1;
for(int i=0;i<n;i++){
a=a+b;
b=a-b;
a=a-b;
a=a+b;
}
cout<<a<<endl;
cout<<fib(n)<<endl;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment