This Python program reads two integers from the user and checks whether each number is divisible by the other.
If both a % b == 0 and b % a == 0 are true, it prints "Yes".
Otherwise, it prints "No".
# Read two numbers from user
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
# Check mutual divisibility
if a % b == 0 and b % a == 0:
print("Yes")
else:
print("No")
Enter the first number: 5
Enter the second number: 5
Yes
Enter the first number: 4
Enter the second number: 2
No
- The program uses the modulo operator % to check for zero remainders
- a % b == 0 means a is divisible by b
- b % a == 0 means b is divisible by a
- Both conditions must be true for the output to be "Yes"
- If either condition fails, the output is "No"