Pascal's Triangle. Students build a block to compute values in Pascal's Triangle, a branched recursive function. The code closely follows the idea that each number in the triangle is the sum of two numbers above it. The project includes some discussion of the efficiency of the recursion, and some options for improving it.
pascal
can differ significantly depending on the algorithm used.pascal
with high inputs: this is the effect of the massive recursion. Including a visible counter variable can show students that things are working. However, you'll need to watch for the difference between a long recursion, and an infinite one caused by an error in base cases.