The Lucas Link
MediumAcc. 93.4%
+25 XP 10
The Second Sequence
The Lucas Sequence is very similar to Fibonacci, but it starts with 2 and 1. Each subsequent number is still the sum of the previous two (2, 1, 3, 4, 7, 11...).
The Assignment
Your function receives a parameter count.
- Initialize
prev = 2andcurr = 1. - Use a loop to print exactly
countnumbers from the sequence. - Calculate the next number, shift the values, and repeat.
01EXAMPLE 1
Input
count=5Output
2
1
3
4
7Explanation: First 5 Lucas numbers.
Constraints
- Print each number on a new line.
- Use a while or for loop.
LoopsMath
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
count5
Expected Output
2 1 3 4 7
Click RUN to test your solution