series program in c

 print following series
1 3 8 15 27 50 92 169 311

#include<stdio.h>
void main()
{
    int x=1, y=3, z=4, n=10, sum, j;
    printf("%d %d ",x,y,z);
    for(j=4; j<=n; j++)
    {
        sum = x+y+z;
        printf("%d ",sum);
      x = y;
      y = z;
      z = sum;
    }
}

Related Posts