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



In mathematics, Divisibility helps us to determine whether a number can be divided by another without leaving a remainder. For example, 6 is divisible by 2 because 6/2 = 3 with no remainder.

In this article, we are going to learn how to check if any large number is divisible by 19 or not in Python.

Checking if any Large Number is Divisible by 19

Checking for the divisibility with small numbers can be easily handled by using the standard arithmetic operations. While dealing with the large numbers (contains 20,30 or even 100 digits), the programming languages may run into issues due to size limits on integers.

But Python has a built-in int data type that can handle arbitrarily large integers. i.e., we can input and process extremely large numbers in Python without any special libraries or configurations.

Scenario 1

Input: 133
Output: True
Explanation: The given input 133 is divisible by 19 (133 ÷ 19 = 7, remainder 0).

Scenario 2

Input: 9988688236837413373
Output: False
Explanation:The given large number leaves a remainder when divided by 19, so it is not divisible.

Let's dive into the example to understand more about checking if any large number is divisible by 19 or not.

Using Modulus Operator (%)

The Modulus operator is used to return the remainder of the division between two numbers. It is denoted by the symbol '%'.

Syntax

The following is the syntax for the Python modulus operator:

number % divisor

In this example, we are using the condition number % 19==0 to check whether the number is divisible by 19 or not. If the condition is satisfied, it returns true; otherwise, it returns false.

Example 1

Let's look at the following example, where we are going to check whether the number 133 is divisible by 19 or not.

def demo(x):
   x = int(x)
   return x % 19 == 0
result = demo(133)
print(result)

Following is the output of the above program:

True

Example 2

In the following example, we are going to consider a large integer and check whether it is divisible by 19 or not.

def demo(x):
   x = int(x)
   return x % 19 == 0
result = demo(9988688236837413373)
print(result)

If we run the above program, it will generate the following output:

False
Updated on: 2025-08-07T13:10:58+05:30

408 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements