Python Program for Find remainder of array multiplication divided by n

This article will learn to find the remainder of array multiplication divided by n using the python program.


Explanation:

arr = [11, 5, 4, 13, 7, 17]

Therefore,

11 % 3 = 2
5 % 3 = 2
4 % 3 = 1
13 % 3 = 1
7 % 3 = 1
17 % 3 = 2

Result = (2*2*1*1*1*2) % 3 = 2


Program

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# array
arr = [11, 5, 4, 13, 7, 17]
n = 3

# now we initialize the count variable 
count = 1

# now we iterate the arr 
for i in range(0, len(arr)):
    # add to count of remainder of array multiplication divided by n
    count = count* (arr[i]%n)
    

# print the result
print(count%n)


Output

2
Next Post Previous Post
No Comment
Add Comment
comment url