dsa8 min read
Prime Factorization Explained — Trial Division, Smallest Prime Factor Sieve in O(log n) [LC 952, Amazon, Microsoft]
Prime factorization is the workhorse of number-theoretic interview problems at Amazon and Microsoft. Master trial division in O(sqrt n), the smallest-prime-factor sieve for batched factorization in O(log n) per query, and the divisor-counting tricks they unlock.
Read →