Try using the following steps.
Within the function declare a variable k and check the condition within the while loop.
STEP1:Using modulo operator check if the variable k is a multiple of n.
STEP2:Increment the value of k every time to another variable(sum) if the above condition is True.
Within the function declare a variable k and check the condition within the while loop.
k=1 while(k<(n-1)): .....step1 .....step2 k+=1
STEP1:Using modulo operator check if the variable k is a multiple of n.
STEP2:Increment the value of k every time to another variable(sum) if the above condition is True.