PHP Count Div
function countDiv(int $a, int $b, int $k): int
{
    $firstDiv = $a % $k === 0 ? $a : $a + ($k - $a % $k);
    $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.