Skip to content

Latest commit

 

History

History
21 lines (11 loc) · 1.12 KB

README.md

File metadata and controls

21 lines (11 loc) · 1.12 KB

Pascal Triangle

What is a Pascal Triangle? For the 1% of the mathematically inclined it is just "a triangular array of the binomial coefficients". For us, the 99% of mere mortals, we know a Pascal Triangle when we see it:

How to gif

Wikipedia Link

This week's exercise is to generate a Pascal Triangle two ways:

  • recursively, with a method that calls itself again and again.
  • iteratively, a.k.a. non recursively (go figure), carry forward your results as you compute the triangle.

If dutifully inclined spend a minute to think about the costs and benefits of each approach.

Extra Points:

Pat in the Back: Google how to implement tail recursion in Ruby (or language of your choice). See if it can be applied to your recursive code.

Standing Ovation: Take a Pascal Triangle, will travel. Can you think of other ways to use PTs in a freaky weird way? One idea pops to mind, use Pascal Triangles + graphics gem to create fractals (hint: Sierpinski).