Learn how to print Lucas sequence in C programming language. It is important that we should know **How A For Loop Works **before getting further with the C program code.

With the code below, you can print the first N terms of Lucas Series in C programming.

#### What is a Lucas Sequence?

A Lucas series is a sequence of numbers which the next number is calculated by adding the immediate preceding two consecutive numbers.

**Note: The first two digits in a Lucas series are always 2 and 1.**

To generate N terms in a Lucas series, the first digit in the sequence should be 2 and the next digit should be 1, which is basically hard-coded. The next digit, which is called as Lucas number, is derived by

The next digit, which is called as Lucas number, is derived from the sum of the preceding two digits in the sequence. This addition and generation of Lucas sequence go till the limit.

#### Example

**2 1 3 4 7 11 18 29 47 76 143 219**

#### Method 1: C Program To Print Lucas series using For Loop

#include<stdio.h> int main() { int first_term, second_term, third_term; int limit, count; printf("Enter the Limit:\t"); scanf("%d", &limit); first_term = 2; second_term = 1; for(count = 0; count < limit; count++) { printf("%d\t", first_term); third_term = first_term + second_term; first_term = second_term; second_term = third_term; } return 0; }

#### Method 2: C Program To Generate First N Terms of Lucas sequence using Function

#include<stdio.h> void lucas_series(int x, int y, int z, int limit) { int count; for(count = 0; count < limit; count++) { z = x + y; printf("%d\t", z); x = y; y = z; } } int main() { int first = 2, second = 1, third = 0; int limit; printf("\nEnter the Limit:\t"); scanf("%d", &limit); printf("\n%d\t%d\t", first, second); lucas_series(first, second, third, limit); return 0; }

#### Output

In case you get any compilation errors in the above program to print first N terms of Lucas sequence in C programming language using For Loop and Functions or if you have any doubts about it, let us know about it in the comment section below.

This is just so similar to Fibonacci sequences. I didn’t even know that anything called as Lucas series exists. Thanks.

Thank you so much!