Counting Common Terms in Two Arithmetic Progressions Within a Range

Given two arithmetic progressions $A_i = a_1 i + b_1$ and $B_i = a_2 i + b_2$ for $i \in \mathbb{N}$, and integers $l \leq r$, determine how many integers $n \in [l, r]$ appear in both sequences. We seek integer solutions $(x, y) \in \mathbb{N}^2$ to the equation: $$ a_1 x + b_1 = a_2 y + b_2 $$ Rewriting gives the linear Diophantine equation: ...

Posted on Fri, 02 Oct 2026 16:01:46 +0000 by robster