6 kyu

Pascal's Triangle #2

1,838 of 5,834Jeroko

Description:

Here you will create the classic Pascal's triangle.
Your function will be passed the depth of the triangle and your code has to return the corresponding Pascal's triangle up to that depth.

The triangle should be returned as a nested array. For example:

pascal(5) -> [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]

To build the triangle, start with a single 1 at the top, for each number in the next row you just take the two numbers above it and add them together, except for the edges, which are all 1. e.g.:

      1
    1   1
  1   2   1
1   3   3   1
Arrays
Algorithms

Stats:

CreatedNov 26, 2013
PublishedNov 26, 2013
Warriors Trained12967
Total Skips2968
Total Code Submissions18396
Total Times Completed5834
JavaScript Completions1838
Ruby Completions532
Python Completions2185
Java Completions1082
Clojure Completions83
Scala Completions41
C# Completions150
Haskell Completions39
λ Calculus Completions7
Julia Completions16
Total Stars220
% of votes with a positive feedback rating87% of 750
Total "Very Satisfied" Votes593
Total "Somewhat Satisfied" Votes114
Total "Not Satisfied" Votes43
Ad
Contributors
  • Jeroko Avatar
  • jhoffner Avatar
  • dividead Avatar
  • Unnamed Avatar
  • GiacomoSorbi Avatar
  • sbatten1969 Avatar
  • anter69 Avatar
  • Chrono79 Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • ThorstenLudwig Avatar
  • Voile Avatar
  • neilm Avatar
  • hobovsky Avatar
  • xavierguihot Avatar
  • stellartux Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • gyon9 Avatar
  • 4500zenja1 Avatar
Ad