TypeScript Count Div
function countDiv(a: number, b: number, k: number): number {
const firstDiv = a % k === 0 ? a : a + (k - (a % k));
const lastDiv = b - (b % k);
return (lastDiv - firstDiv) / k + 1;
}
This counts how many numbers in a range are divisible by K without looping through every value.