Problem 1845. Pascal's pyramid
In Pascal's triangle each number is the sum of the two nearest numbers in the line above:
           1
         1   1
       1   2   1
     1   3   3   1
   1   4   6   4   1A three-dimensional analog of Pascal's triangle can be defined as a square pyramid in which each number is the sum of the four nearest numbers in the layer above. Define a function pascalp(n) that returns the nth layer of this pyramid, as follows:
   pascalp(1)
      1
   pascalp(2)
      1  1
      1  1
   pascalp(3)
      1  2  1
      2  4  2
      1  2  1
   pascalp(4)
      1  3  3  1
      3  9  9  3
      3  9  9  3
      1  3  3  1
   pascalp(5)
      1  4  6  4 1
      4 16 24 16 4
      6 24 36 24 6
      4 16 24 16 4
      1  4  6  4 1Note: Pascal's pyramid can also be defined as a tetrahedron (see http://en.wikipedia.org/wiki/Pascal%27s_pyramid), in which case the layers are triangular rather than square, and the numbers are the trinomial coefficients.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers121
Suggested Problems
- 
         Compute a dot product of two vectors x and y 1021 Solvers 
- 
         Count letters occurence in text, specific to words with a given length. 179 Solvers 
- 
         Convert Two Character String into a Binary Vector 218 Solvers 
- 
         Is this triangle right-angled? 6231 Solvers 
- 
         
         1173 Solvers 
More from this Author11
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!