# Check if any large number is divisible by 19 or not in Python

PythonServer Side ProgrammingProgramming

Suppose, we are given a large number and we have to check whether the number is divisible by 19.

So, if the input is like 86982, then the output will be “Divisible”.

We will solve this problem using the repeated addition method, where we extract the last digit from the number, multiply it with 2, and add the result to the remaining number until we get a two-digit number that is divisible by 19.

To solve this, we will follow these steps −

• while the number is divisible by 100, do
• last_digit := number mod 10
• number := floor value of (number divided by 10)
• number := number + last_digit * 2
• return True, if number mod 19 is same as 0.

Let us see the following implementation to get better understanding −

## Example

Live Demo

def solve(number) :
while(number // 100) :
last_digit = number % 10
number //= 10
number += last_digit * 2
return (number % 19 == 0)
number = 86982
if solve(number) :
print("Divisible")
else :
print("Not Divisible")

## Input

86982

## Output

Divisible
Published on 30-Dec-2020 13:02:30