Master Mathematical Algorithms for Coding Interviews
Definition: A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Purpose: Find all prime numbers up to a given limit efficiently.
Key Point: 0! = 1 by definition
Why: Trailing zeros come from factors of 10 = 2 Ć 5, and there are always more factors of 2 than 5.
Extract digits using modulo and integer division
Sum all digits in a number
Check if number reads same forwards and backwards
Number equals sum of its proper divisors
Example: 28 = 1 + 2 + 4 + 7 + 14
Problem: Calculate a^n efficiently
Iteratively refine the guess until desired precision