Given a number N. The task is to find the sum of numbers from 1 to N, which are present in the Lucas Sequence.
The Lucas numbers are in the following integer sequence:
2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123 ......
Input : N = 10 Output : 17 Input : N = 5 Output : 10
- Loop through all the Lucas numbers which are less than the given value N.
- Initialize a sum variable with 0.
- Keep on adding these lucas numbers to get the required sum.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Longest sub-sequence of array containing Lucas numbers
- Lucas Numbers
- Jacobsthal and Jacobsthal-Lucas numbers
- Arrange numbers to form a valid sequence
- Find the K-th Permutation Sequence of first N natural numbers
- Find a sequence of N prime numbers whose sum is a composite number
- Compute nCr % p | Set 2 (Lucas Theorem)
- Lucas Primality Test
- Primality Test | Set 5(Using Lucas-Lehmer Series)
- Sum of the sequence 2, 22, 222, .........
- Look-and-Say Sequence
- Beatty sequence
- Aliquot Sequence
- Juggler Sequence
- Find F(n) when F(i) and F(j) of a sequence are given
- Padovan Sequence
- Golomb sequence
- Recaman's sequence
- Gould's Sequence
- Alcuin's Sequence
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.