human
Find sum of modulo K of first N natural number | Return sum of modulo K of first N natural numbers ..
Counting the number of times 1 , 2 , . . , K - 1 , 0 sequence occurs ..
Finding the number of elements left which are incomplete of sequence Leads to Case 1 type ..
adding multiplication of number of times 1 , 2 , . . , K - 1 , 0 sequence occurs and sum of first k natural number and sequence from case 1..
Driver Code"
Solution in Python:
assistant
#Here is code to find sum of modulo K of first N natural number and the other steps required.
 def findSum ( N , K ) :
	ans = 0 ;
	y = N / K ;
	x = N % K ;
	ans = ( ( K * ( K - 1 ) / 2 ) * y + ( x * ( x + 1 ) ) / 2 ) ;
	return int ( ans ) ;
N = 10 ;
K = 2 ;
print ( findSum ( N , K ) ) ;