#include<bits/stdc++.h>
using namespace std;
#define lim 5001
#define len 1050
long long fib[lim][len],i,j;
void fibonacci()
{
fib[0][0]=0;
fib[1][0]=1;
fib[2][0]=1;
for(i=3;i<lim;i++)
{
for(j=0;j<len;j++)
{
fib[i][j]+=fib[i-2][j]+fib[i-1][j];
if(fib[i][j]>9)
{
fib[i][j+1]+=fib[i][j]/10;
fib[i][j]=fib[i][j]%10;
}
}
}
}
main()
{
fibonacci();
long long n;
while(cin>>n)
{
printf("The Fibonacci number for %lld is ",n);
{
//n+=2;
for(i=len-1;i>0;i--)
{
if(fib[n][i]!=0)
{
break;
}
}
for(;i>=0;i--)
cout<<fib[n][i];
cout<<endl;
}
}
}
using namespace std;
#define lim 5001
#define len 1050
long long fib[lim][len],i,j;
void fibonacci()
{
fib[0][0]=0;
fib[1][0]=1;
fib[2][0]=1;
for(i=3;i<lim;i++)
{
for(j=0;j<len;j++)
{
fib[i][j]+=fib[i-2][j]+fib[i-1][j];
if(fib[i][j]>9)
{
fib[i][j+1]+=fib[i][j]/10;
fib[i][j]=fib[i][j]%10;
}
}
}
}
main()
{
fibonacci();
long long n;
while(cin>>n)
{
printf("The Fibonacci number for %lld is ",n);
{
//n+=2;
for(i=len-1;i>0;i--)
{
if(fib[n][i]!=0)
{
break;
}
}
for(;i>=0;i--)
cout<<fib[n][i];
cout<<endl;
}
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন