Lucas numbers: It is similar to Fibonacci numbers, each Lucas number is defined to be the sum of its two immediate previous terms Where as the first two number are 2 and 1.
The Lucas numbers are as following :
2 1 3 4 7 11 18 29 47 76
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,num;
printf("Enter the limit of Lucas number : ");
scanf("%d",&num);
x=2;
y=1;
while(num>=x)
{
printf(" %d",x);
z=x+y;
x=y;
y=z;
}
getch();
getch();
return 0;
}
/***************Output***************
Enter the limit of Lucas number : 125
2 1 3 7 11 18 29 47 76 123
************************************/
************************************/
Related Programs:
0 comments:
Post a Comment