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

Sign in to watch this lesson
Advanced - Number Theory · 3:54
The equation a·x + b·y = c has integer solutions exactly when g = gcd(a, b) divides c, and one solution comes from extended Euclid scaled by c/g. All solutions lie evenly spaced on a line, x = x0 + k·b/g and y = y0 − k·a/g, so counting them inside limits means intersecting two ranges of k with floor division, and any linear cost is optimal at an end of that range.