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.
- Use an iterative loop to calculate members up to
n. - To avoid massive numbers, use the shortcut: $e_n = e_{n-1}^2 - e_{n-1} + 1$.
- Print each member on a new line.
01EXAMPLE 1
Input
n = 3Output
2
3
7Explanation: First three members.
Constraints
- Use the quadratic recurrence formula.
- Stop after N members.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
n3
Expected Output
2 3 7
Click RUN to test your solution