We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<iostream>usingnamespacestd;voidfibonacci(intn,int*fn,int*fn1){// Complete the function.if(n==1){*fn=1;*fn1=0;return;}intfn_,fn1_;fibonacci(n-1,&fn_,&fn1_);*fn=fn_+fn1_;*fn1=fn_;}intmain(){intn;intfn,fn1;cin>>n;fibonacci(n,&fn,&fn1);cout<<fn;return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Recursion: Fibonacci Numbers
You are viewing a single comment's thread. Return to all comments →