Problem 37. Pascal's Triangle
Given an integer n >= 0, generate the length n+1 row vector representing the n-th row of Pascal's Triangle.
Examples:
pascalTri(0) ans = 1
pascalTri(1) ans = 1 1
pascalTri(2) ans = 1 2 1
Solution Stats
Problem Comments
-
5 Comments
the last assertion is wrong
Oops, I guess I commented in the solution, not the problem. (What's the difference????) They should check if their answer is symmetrical, which it isn't, so their solution must be wrong regardless of subsequent values
I've removed the last assertion and rescored. Thanks for the note.
fun!
Fun!!
Solution Comments
Show commentsProblem Recent Solvers4113
Suggested Problems
-
2177 Solvers
-
How to find the position of an element in a vector without using the find function
2690 Solvers
-
Find out missing number from a vector of 9 elements
290 Solvers
-
4632 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1332 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!