Python BasicsEasy

Automorphic number

Detailed guide and Python implementation for the 'Automorphic number' problem.

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?
Consider using Basics-specific data structures like sets or heaps.
Edge Cases to Watch
  • Empty input structures
  • Single element inputs
  • Large numerical bounds

Ready to Solve?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Open in Editor

Recommended Python Resources

Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.