Check Divisible by 5 and 11

Check whether a given integer is divisible by both 5 and 11.

PythonBeginner

What You'll Learn

  • Checking multiple conditions with and
  • Using modulo for divisibility tests
  • Combining simple conditions into composite logic
Python
# Program to check if a number is divisible by both 5 and 11

num = int(input("Enter an integer: "))

if num % 5 == 0 and num % 11 == 0:
    print(num, "is divisible by both 5 and 11")
else:
    print(num, "is not divisible by both 5 and 11")

Output

Enter an integer: 55
55 is divisible by both 5 and 11

We use the modulo operator and logical AND:

  • num % 5 == 0 checks divisibility by 5.
  • num % 11 == 0 checks divisibility by 11.
  • Both must be true simultaneously for the number to be divisible by both.

Step-by-Step Breakdown

  1. 1Read an integer from the user.
  2. 2Compute num % 5 and num % 11.
  3. 3If both remainders are zero, print that it is divisible by both.
  4. 4Otherwise, print that it is not.