Counting GCD Values in Range Using Integer Division Block

Given integers l, r, and k, determine how many distinct greatest common divisors (GCDs) can be formed by selecting any k numbers from the range [l, r]. The constraint is: 1 ≤ l ≤ r ≤ 10^12, 2 ≤ k ≤ r - l + 1. Rather than computing all possible GCD values directly, we count all potential divisors. Any integer m = i × j that divides two numbers x ...

Posted on Thu, 27 Aug 2026 16:53:21 +0000 by AMCH