- Related Questions & Answers
- Check if binary representation of a number is palindrome in Python
- Check if any permutation of a large number is divisible by 8 in Python
- Check if any large number is divisible by 17 or not in Python
- Check if any large number is divisible by 19 or not in Python
- Check if any permutation of a number is divisible by 3 and is Palindromic in Python
- Check if number is palindrome or not in Octal in Python
- Check if a large number is divisible by 20 in C++
- Check if a number is divisible by all prime divisors of another number in C++
- Check if LCM of array elements is divisible by a prime number or not in Python
- Check if a number is divisible by 23 or not in C++
- Check if a number is divisible by 41 or not in C++
- C Program to check if a number is divisible by sum of its digits
- C Program to check if a number is divisible by any of its digits
- Check if a large number is divisible by 11 or not in java
- Check if a large number is divisible by 3 or not in java

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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 −

- sum := 0
- while num is non-zero, do
- sum := sum + (num mod 10)
- num := quotient of (num / 10)

- if sum mod 7 is same as 0, then
- return True

- return False

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

Advertisements