Tuesday, 5 September 2017

Write a program to generate the series 1 3 4 8 15 27 50 92 169 311 ....



#include<stdio.h>

 int main()
 {
 int a=1,b=3,c=4,d,i,n;
 scanf("%d",&n);
 printf("%d %d %d ",a,b,c);
 for(i=4;i<=n;i++)
 {
 d=a+b+c;
 printf("%d ",d);
 a=b;
  b=c;
 c=d;
 }
 return(0);
 }

No comments:

Post a Comment