Check Automorphic Number
Check whether a number is automorphic (its square ends with the same digits).
BeginnerTopic: Conditional Programs
Python Check Automorphic Number Program
This program helps you to learn the fundamental structure and syntax of Python programming.
# Program to check automorphic number
num = int(input("Enter an integer: "))
square = num * num
if str(square).endswith(str(num)):
print(num, "is an automorphic number")
else:
print(num, "is not an automorphic number")Output
Enter an integer: 25 25 is an automorphic number
Understanding Check Automorphic Number
An automorphic number appears at the end of its own square (e.g., 25 → 625).
We convert both to strings and use endswith() to test the property.
Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.