Stern's Diatomic
HardAcc. 71.6%
+45 XP 25
The Binomial Alternative
Stern's diatomic sequence $s_n$ is defined as: $s_0 = 0, s_1 = 1$ $s_{2n} = s_n$ $s_{2n+1} = s_n + s_{n+1}$
The Assignment
Your function receives a parameter n.
- use a loop to build the sequence up to
n. - Print only the
n-th value (s[n]).
01EXAMPLE 1
Input
n = 3Output
2Explanation: s0=0, s1=1, s2=1, s3=1+1=2.
Constraints
- Iterative implementation.
- Result is a single number.
MathLoopsLogic
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
n3
Expected Output
2
Click RUN to test your solution