previous |
start |
next
Triangle Numbers
- Here's how the area is computed for a triangle
of width 4.
- The get_area function makes a smaller
triangle of width 3.
- It calls get_area on that
triangle.
- That function makes a smaller triangle of width
2.
- It calls get_area on that
triangle.
- That function make a smaller triangle of width
1.
- It calls get_area on that
triangle.
- That function returns 1.
- The function returns smaller_area +
width = 1 + 2 = 3.
- The function returns smaller_area +
width = 3 + 3 = 6.
- The function returns smaller_area +
width = 6 + 4 = 10.
previous |
start |
next