Write a code so that 1 candy is given to the 1st boy, then 2 candies to the 2nd boy, 3 candies to the 3rd boy, and so on up to K candies, then return to the 1st boy and continue with (N+1) candies until you finish; for example, K=7 and N=3 should output (1,2,3,1). Treat K as the total number of candies and N as the number of boys. Return the 1-based boy numbers receiving each allocation, including the final partial allocation when fewer candies remain.
def distribute_candies(k, n):