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.

  1. Initialize prev = 2 and curr = 1.
  2. Use a loop to print exactly count numbers from the sequence.
  3. Calculate the next number, shift the values, and repeat.

01EXAMPLE 1

Inputcount=5
Output2 1 3 4 7

Explanation: First 5 Lucas numbers.

Constraints

  • Print each number on a new line.
  • Use a while or for loop.
LoopsMath
JavaScript
Loading...
3 Hidden

Input Arguments

count5

Expected Output

2
1
3
4
7

Click RUN to test your solution