Hello,
I was working on a practice problem from an online source (cprogramming.com). The problem was to calculate any given position on Pascal's Triangle and print out the number. Evenatually, I viewed their solution. This function is confusing to me:
Now you can see that position is 1 in any row the answer is 1. This is the first if check.
You can see that at the end of each row the value is 1 and the number of positions is equal to the row number, so this is if check number two.
And the else, if you follow the steps up you can see that each number (not on the ends) depend on the two numbers in the previous row. The one directly above in the same position [ compute_pascal(row-1, position) ] and the number before that number [compute_pascal(row-1, position-1) ]. That dependence is the sum of those two numbers.