We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8934bab commit c853e30Copy full SHA for c853e30
maths/automorphic_number.py
@@ -0,0 +1,24 @@
1
+def is_automorphic(n: int) -> bool:
2
+ """
3
+ Check if a number is an Automorphic Number.
4
+ A number is automorphic if its square ends with the number itself.
5
+
6
+ Examples:
7
+ >>> is_automorphic(5)
8
+ True
9
+ >>> is_automorphic(6)
10
11
+ >>> is_automorphic(76)
12
13
+ >>> is_automorphic(7)
14
+ False
15
16
+ Time Complexity: O(d) where d is number of digits
17
18
+ square = n * n
19
+ return str(square).endswith(str(n))
20
21
22
+if __name__ == "__main__":
23
+ import doctest
24
+ doctest.testmod()
0 commit comments