Fibonacci pattern(4)

Question-
0
1 1
2 3 5
8 13 21 34
In this code of mine one of thetest case is failing
Solution
#include
using namespace std;
int main()
{
int n;
cin>>n;
cout<<“0”<<endl;
int a=1;
int b=1;
int s=0;
cout<<a<<" “<<b<<endl;
int k=3;
for(int i=3;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
s=a+b;
k=k+1;
if(k<=(n*(n+1)/2))
cout<<s<<” ";
a=b;
b=s;
}
cout<<endl;
}
return 0;
}

handle n=1 separately
for n=1 your code will print
0
1 1
instead of
0