FunctionRacerProblemsRace

Kth Number in the Times Table

HardMathPython, JavaScript, TypeScript, Java, C++

A times table has rows rows and cols columns. The cell in row r and column c, both counted from 1, holds r * c.

Return the kth smallest number in the table. A number that appears in several cells is counted once per cell.

Example 1

rows 3
cols 3
k 7
returns 6

In order the table reads 1, 2, 2, 3, 3, 4, 6, 6, 9. The seventh number is 6.

Example 2

rows 2
cols 5
k 6
returns 4

In order the table reads 1, 2, 2, 3, 4, 4, 5, 6, 8, 10. The sixth number is 4.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems