Math Fundamentals18 sections · 814 units
Open in Course

Lessons from Add Digits

summary

Three points:

1.1. A number and the sum of its digits are congruent modulo 99. This property enables shortcuts.

2.2. Sometimes a mathematical formula replaces a loop. The formula is faster and cleaner.

3.3. Edge cases matter. n=0n = 0 needs special handling because the formula assumes n>0n > 0.