Check Automorphic Number

Check whether a number is automorphic (its square ends with the same digits).

PythonBeginner
Python
# 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

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.