XXXII - II - Task 4

Given are natural numbers $ k, n $. We define inductively two sequences of numbers $ (a_j) $ and $ (r_j) $ as follows:
First step: divide $ k $ by $ n $ and obtain the quotient $ a_1 $ and the remainder $ r_1 $,
j-th step: divide $ k + r_{j-1} $ by $ n $ and obtain the quotient $ a_j $ and the remainder $ r_j $. Calculate the sum $ a_1 + \ldots + a_n $.