Back to Practice Dashboard
Python BasicsEasy
Automorphic number
Learn how to solve the 'Automorphic number' problem. This detailed resource details brute force and optimized approaches.
Problem Statement
Easy
Write a function is_automorphic(n) that takes a non-negative integer n and returns True if n is an automorphic number, or False otherwise. An automorphic number is a number whose square ends with the number itself. For example, 25 is automorphic because 25^2 = 625, which ends with 25.
Constraints
- •0 <= n <= 10^6
Examples
Example 1
Input
n = 25
Output
True
Explanation
25^2 = 625. The last two digits of 625 are 25, which matches n.
Example 2
Input
n = 76
Output
True
Explanation
76^2 = 5776. The last two digits of 5776 are 76, which matches n.
Example 3
Input
n = 13
Output
False
Explanation
13^2 = 169. The last two digits of 169 are 69, which does not match 13.
Need a Hint?
Use simple arithmetic operators (like modulo `%`, division `//`), conditional checks, or loops to inspect number properties.
Edge Cases to Watch
- Empty list or null input variables
- Single item lists/arrays
- Extremely large input bounds causing integer or stack overflow
Ready to Solve?
Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.