explain this code

The code checks every element in passed arg1, if it is divisible by 5 if it is then the element gets updated with division then it is again checked with 3 and updated if it is divisible by 3.

Here,

- i=0, M[0] = 25 , first if is true so M[0] becomes 5 (25//5) Now second if becomes false and iteration ends. therefore
**M[0] = 5** - i=1, m[1]=8, both ifs become false value remains unchanged,
**M[1]=8** - i=2, M[2]=75, first if becomes true, M[2] = 15 (75//5), second if becomes true M[2]=5 (15//3), iteration ends with
**M[2] = 5** - i=3, M[3]=12, first if becomes false, M[3] = 12, second if becomes true M[3] = 4 (12//3), iteration ends with
**M[3] = 4**

So, output becomes,**5,8,5,4**

1 Like