#include<stdio.h>
int anik(int n)
{
if(n == 0 || n == 1)
return 0;
else if(n == 2)
return 1;
else
return anik(n-1)+anik(n-2)+anik(n-3);
}
int main()
{
int a, i, j = 0;
printf("Enter Any Number : ");
scanf("%d", &a);
printf("\nTribonacci Series : \n");
for(i=1; i<=a; i++)
{
printf("%d\n", anik(j));
j++;
}
printf("\n");
return 0;
}
int anik(int n)
{
if(n == 0 || n == 1)
return 0;
else if(n == 2)
return 1;
else
return anik(n-1)+anik(n-2)+anik(n-3);
}
int main()
{
int a, i, j = 0;
printf("Enter Any Number : ");
scanf("%d", &a);
printf("\nTribonacci Series : \n");
for(i=1; i<=a; i++)
{
printf("%d\n", anik(j));
j++;
}
printf("\n");
return 0;
}
Comments
Post a Comment