Sylvester's Sequence

HardAcc. 68.4%
+45 XP 25

Exponential Explosion

Sylvester's sequence $e_n$ is defined by: $e_0 = 2$ $e_n = 1 + prod_{i=0}^{n-1} e_i$ 2, 3, 7, 43, 1807...

The Assignment

Your function receives a parameter n.

  1. Use an iterative loop to calculate members up to n.
  2. To avoid massive numbers, use the shortcut: $e_n = e_{n-1}^2 - e_{n-1} + 1$.
  3. Print each member on a new line.

01EXAMPLE 1

Inputn = 3
Output2 3 7

Explanation: First three members.

Constraints

  • Use the quadratic recurrence formula.
  • Stop after N members.
MathLoops
JavaScript
Loading...
2 Hidden

Input Arguments

n3

Expected Output

2
3
7

Click RUN to test your solution