Fork Copy 0 && $r >= $number * $count) { $sum += min($r, ($number + 1) * $count - 1) - (($number * $count) - 1); } $count *= 10; $base *= 10; } return $sum; } function calculate($from, $to, $number) { return calculate1ToN($to, $number) - calculate1ToN($from - 1, $number); } echo calculate($argv[1] ?? 1, $argv[2] ?? 100, $argv[3] ?? 7);