The Padovan Pulse

MediumAcc. 92.4%
+25 XP 10

The Plastic Number

The Padovan sequence $P_n$ starts with $P_0=P_1=P_2=1$. Every subsequent number is the sum of the terms two and three positions back: $P_n = P_{n-2} + P_{n-3}$. 1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 12...

The Assignment

Your function receives a parameter n.

  1. Use a loop to calculate the $n$-th member of the sequence.
  2. Print the final number.

01EXAMPLE 1

Inputn = 5
Output3

Explanation: P0=1, P1=1, P2=1, P3=2, P4=2, P5=3.

Constraints

  • Use iterative logic.
  • Handle n=0, 1, 2 correctly.
MathLoopsSequences
JavaScript
Loading...
3 Hidden

Input Arguments

n5

Expected Output

3

Click RUN to test your solution