⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 17m 52s17 days 22 hours 17 minutes 52 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 17m 52s17 days 22 hours 17 minutes 52 seconds.

Sign in to watch this lesson
Algorithms - Bits and Number Theory · 4:50
Instead of testing each number for divisors, let every prime cross out its own multiples. On the 1..16 grid we see the wasted double marks, then start each prime at its square and stop at the square root of n, which brings the work down to about n log log n. Measured on this Mac at n = 10^8, the segmented sieve that works one L1-sized block at a time runs more than five times faster than the plain byte array, and the same block idea finds the primes in a window far from zero.