TCS Consider the series below 0,0,2,1,4,2,6,3,8,4,10,5,12,6….

0,0,2,1,4,2,6,3,8,4,10,5,12,6….

#include<stdio.h>
int main()
{
int i=3,n;
printf(“enter nth term”);
scanf(“%d”,&n);
int a[n+1];
a[1]=0;
a[2]=0;
while(i<=n)
{
if(i%2==0)
a[i]=a[i-2]+1;
else
a[i]=a[i-2]+2;
i++;
}
printf(“%d”,a[n]);
}

Write Code for this

Solution in other languages is not Available as of now- Please add in comments

Please comment explanations below –

Also you can study other coding questions here –