Suppose we have one octal number. We have to check whether the decimal representation of the given octal number is divisible by 7 or not.
So, if the input is like n = 61, then the output will be True as the decimal representation of 61 is 6*8 + 1 = 48 + 1 = 49 which is divisible by 7.So, if the input is like n = 61, then the output will be True as the decimal representation of 61 is 6*8 + 1 = 48 + 1 = 49 which is divisible by 7.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(num): sum = 0 while num: sum += num % 10 num = num // 10 if sum % 7 == 0 : return True return False num = 61 print(solve(num))
61
True