human
Sum of the first M elements of Array formed by infinitely concatenating given array | Function to find the sum of first M numbers formed by the infinite concatenation of the array A [ ].
Stores the resultant sum.
Iterate over the range [ 0 , M - 1 ].
Add the value A [ i % N ] to sum.
Return the resultant sum.
Driver Code"
How can the above be solved in Python?
 ... What is a code to sum of the first M elements of Array formed by infinitely concatenating given array and the other steps required?
assistant
#Here is code to sum of the first M elements of Array formed by infinitely concatenating given array and the other steps required.
 def sumOfFirstM ( A , N , M ) :
	sum = 0
	for i in range ( M ) :
		sum = sum + A [ i % N ]
	return sum
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 ]
	M = 5
	N = len ( arr )
	print ( sumOfFirstM ( arr , N , M ) )