10.02.2011

Lucas number Program

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

/*c program to accept number from user and print less than Lucas numbers*/
#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();
 return 0;
}


/***************Output*************** 

Enter the limit of Lucas number : 125
 2 1 3 7 11 18 29 47 76 123


************************************/

Related Programs:

  1. Amicable number C program
  2. Perfect number C program
  3. Armstrong number C program
  4. Print Armstrong number range C program
  5. Fibonacci series C program
  6. Generate Fibonacci series using recursion
  7. Search number is Fibonacci or not

1 comment: