- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 are given a number and we have to check whether the number is divisible by 17.

So, if the input is like 99943, then the output will be Divisible.

We will solve this problem using the repeated subtraction method, where we extract the last digit of the number and subtract it 5 times from the number until we get a two-digit number that is divisible by 17.

To solve this, we will follow these steps −

- while number is divisible by 100, do
- last_digit := number mod 10
- number := floor value of (number divided by 10)
- number := number - last_digit * 5

- return true if number mod 17 is same as 0.

Let us see the following implementation to get better understanding −

def solve(number) : while(number // 100) : last_digit = number % 10 number //= 10 number -= last_digit * 5 return (number % 17 == 0) number = 99943 if solve(number) : print("Divisible") else : print("Not Divisible")

99943

Divisible

- Related Questions & Answers
- Check if any large number is divisible by 19 or not in Python
- 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
- Check if a large number is divisible by 11 or not in C++
- Check if a large number is divisible by 25 or not in C++
- Check if a large number is divisible by 3 or not in C++
- Check if a large number is divisible by 5 or not in C++
- Check if a large number is divisible by 75 or not in C++
- Check if a large number is divisible by 8 or not in C++
- Check if a large number is divisible by 9 or not in C++
- Check if a large number is divisible by 13 or not in C++
- Check if any permutation of a large number is divisible by 8 in Python
- Check if a large number is divisible by 2, 3 and 5 or not in C++
- Check if a number is divisible by 23 or not in C++
- Check if a number is divisible by 41 or not in C++

Advertisements