This problem has constrain as 0 < n < 100, and we have to compute n*(n+1)/2 Fibonacci number which is very large.
so the answer for even n = 15 comes out wrong, I have used long long int also but still its capacity is not enough.
What should I do?
here is the code -
#include
using namespace std;
int main()
{
int n;
cin>>n;
long long int curr;
long long int p1=0;
long long int p2=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if(i==1 && j==1)
cout<<"0";
else if(i==2 && j==1)
cout<<"1\t";
else
{
curr = p1 + p2;
cout<<curr<<"\t";
p2 = p1;
p1 = curr;
}
}
cout<<endl;
}
return 0;
}