Pascal's Row

HardAcc. 75.6%
+45 XP 25

Combinatorial Flow

The k-th row of Pascal's triangle can be generated using a loop and simple multiplication. Formula: $C(n, k) = C(n, k-1) \times (n-k+1) / k$.

The Assignment

Your function receives rowIndex.

  1. Print the elements of that row on new lines.
  2. The first and last elements are always 1.

01EXAMPLE 1

InputrowIndex = 3
Output1 3 3 1

Explanation: Row 3 of Pascal.

Constraints

  • Iterative row generation.
MathArrays
JavaScript
Loading...
1 Hidden

Input Arguments

rowIndex3

Expected Output

1
3
3
1

Click RUN to test your solution