Header Ads

Learn Together, Stay Connected.

ফিবোনাক্কি নাম্বার-C


#include<stdio.h>
#include<math.h>
long long int fibo_dp(long long int n)
{
long long int fib[n+1];
fib[0]=0;
fib[1]=1;
if(n<2)
return n;
else
{
for(int i=2;i<=n;i++)
{
fib[i]=fib[i-1]+fib[i-2];
}
return fib[n];

}


}
int main()
{
long long int x;
scanf("%lld",&x);
printf("%lld\n",fibo_dp(x));

return 0;
}

No comments

Theme images by Dizzo. Powered by Blogger.