Home Forums C Programming how to create a program of Lucas No. using Turbo C Re: how to create a program of Lucas No. using Turbo C

#3333
yeswanth
Participant

The first few numbers of Lucas sequences which is a variation of Fibonacci sequence are sequence are
1 3 4 7 11 18 29
a) Design a program in C to generate Lucas sequence.
b) Develop a function to calculate sum of first n odd integers.

#include 
#include
void main()
{
int num,i;
unsigned long n1=1,n2=3,s;
clrscr();
printf("nENTER A NUMBER: ");
scanf("%d",&num);
printf("nLUCAS SEQUENCE UPTO %d NUMBERS IS: n",num);
printf("%lu %lu",n1,n2);
for(i=1;i<=num-2;i++)
{
s=n1+n2;
printf(" %lu",s);
n1=n2;
n2=s;
}
getch();
}