Skip to main content
2 of 3
added 7 characters in body
user avatar
user avatar

#C#

Uses the recurrence relation x(n)=x(n-1)+x(n-3)+x(n-5) to generate the sequence

#include <stdio.h>

int main()
{
int i,j;
    while(1)
    {
    int n[7]={0,-3,7,0,-3,-1,0};
    n[3]=-2*(n[1]+n[5]);
        for(j=0;j<6;j++)
        {
        n[6]=n[5]+n[3]+n[1];
            for(i=1;i<6;i++)n[i]=n[i+1];
        printf("%d\n",n[6]);
        }
    }
    return 0;
}