Purpose: Validation, summation, etc... Excellent example of how math is applied in a programming context. Also, the concept of numerical bases.

Quote

Given a number, write a function that sums its digits and returns that sum

To extract each digit we need to divide the number by its base. The traditional numbers with which we work are base 10 or decimal. Each iteration we extract a digit by getting the remainder of the number divided by ten and then dividing the number by ten and assigning the number that value:

There are a few optimizations one could make, like immediately filtering out known composite numbers, or changing the incremental values, but for the purposes of quick illustration, the above function is satisfactory.

6. Aggregation versus Composition

Purpose: How to manage an object's lifetime. Object relationships.

In short, an object has control over another. If the parent object destroys the child object when it is destroyed then the relationship is composition. If the child object continues to exist after the parent object is destroyed, it is aggregation.

One example is college. The college hires professors, but if the school shuts down, the professors continue on being professors, their lifetime (in the terms of a modeled program) does not end with the destruction of their "owner".