Suppose we have a number n, we have to check whether the product of digits at even places of n is divisible by sum of digits at odd place of n or not. Places are started counting from right to left. Right most is at place 1.
So, if the input is like n = 59361, then the output will be True as (1*3*5) = (6+9).
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
from math import log10 def solve(n): digit_count = int(log10(n))+1 total = 0 prod = 1 while n > 0 : if digit_count % 2 == 0 : prod *= n % 10 else: total += n % 10 n = n // 10 digit_count -= 1 if prod % total == 0: return True return False n = 59361 print(solve(n))