Given a number N, check whether the number is Automorphic number or not.
A number is called Automorphic number if and only if its square ends in the same digits as the number itself. 
 
Example 1:
Input: N = 76
Output: Automorphic
Explanation: 76^{2} = 5776 which ends with 
76 therefore it is a automorphic number.
Example 2:
Input: N = 16
Output: Not Automorphic
Example: 16^{2} = 256 is not ending with 16.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function is_AutomorphicNumber() which takes n as input parameter and returns "Automorphic" if it is Automorphic number otherwise returns "Not Automorphic"(Without quotes).
 
Expected Time complexity: O(log(N))
Expected Space Complexity: O(1)
Constranits:
1 <= N <= 1000

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

	def is_AutomorphicNumber(self, n):

		# Code here



Solutions:
class Solution:

	def is_AutomorphicNumber(self, n):
		s = n ** 2
		q = str(s)
		n = str(n)
		if q.endswith(n):
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		square = n * n
		square = str(square)
		n = str(n)
		if square.endswith(n):
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		num_length = len(str(n))
		sqr = n * n
		sqr_str = str(sqr)
		if sqr_str.endswith(str(n)):
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		n_str_list = list(str(n))
		L = len(n_str_list)
		n_2_str_list = list(str(n * n))
		L_2 = len(n_2_str_list)
		if L == L_2:
			if n_2_str_list == n_str_list:
				return 'Automorphic'
			else:
				return 'Not Automorphic'
		for i in range(0, L):
			if not n_2_str_list[L_2 - i - 1] == n_str_list[L - i - 1]:
				return 'Not Automorphic'
		return 'Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		res = 'Automorphic' if str(n ** 2).endswith(str(n)) else 'Not Automorphic'
		return res


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n ** 2
		n = str(n)
		sq = str(sq)
		com = sq[-len(n):]
		if n == com:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		wno = n ** 2
		if wno % 10 == n:
			return 'Automorphic'
		elif wno % 100 == n:
			return 'Automorphic'
		elif wno % 1000 == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		num = n
		t = 10
		sq = n ** 2
		Flag = False
		while n > 0:
			r = sq % t
			if num == r:
				Flag = True
				break
			n //= 10
			t *= 10
		if Flag:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		x = n ** 2
		n = str(n)
		x = str(x)
		y = x[-len(n):]
		if n == y:
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = str(n ** 2)
		if sq.endswith(str(n)):
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		s = len(str(n))
		sq = n ** 2
		sq = str(sq)
		if int(sq[-s:]) == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		if n ** 2 % 10 ** len(str(n)) == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		if str(n * n).endswith(str(n)) == True:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n ** 2
		numstr = str(n)
		sqnumstr = str(sq)
		revnum = numstr[::-1]
		revsqnum = sqnumstr[::-1]
		for i in range(0, len(revnum)):
			if revnum[i] == revsqnum[i]:
				continue
			else:
				return 'Not Automorphic'
		return 'Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = n * n
		k = str(n)
		s = str(a)
		if s.endswith(k):
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		if n in [1, 5, 6]:
			return 'Automorphic'
		elif n == 1000:
			return 'Not Automorphic'
		elif n >= 100 and n <= 999:
			if n * (n - 1) % 1000 == 0:
				return 'Automorphic'
			else:
				return 'Not Automorphic'
		elif n * (n - 1) % 100 == 0:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n * n
		sq = str(sq)
		sn = str(n)
		n_len = len(sn)
		if sq[-n_len:] == str(n):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		st = len(str(n))
		s = n ** 2
		i = 0
		h = ''
		while i < st:
			h += str(s % 10)
			s = s // 10
			i += 1
		if n == int(h[::-1]):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		if len(str(n)) == 3:
			if n ** 2 % 1000 == n:
				return 'Automorphic'
			else:
				return 'Not Automorphic'
		elif len(str(n)) == 2:
			if n ** 2 % 100 == n:
				return 'Automorphic'
			else:
				return 'Not Automorphic'
		elif len(str(n)) == 1:
			if n ** 2 % 10 == n:
				return 'Automorphic'
			else:
				return 'Not Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		N = str(n * n)
		n = str(n)
		if n == N[-len(n):]:
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		m = n * n
		(s, a) = (str(m), str(n))
		if a[::-1] == s[:-len(a) - 1:-1]:
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = str(n)
		n1 = n ** 2
		b = str(n1)
		if b.endswith(a):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		num = str(1)
		squared_no = n ** 2
		for i in range(len(str(n))):
			num += str(0)
		endswith = squared_no % int(num)
		if n == endswith:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		num = str(n)
		return 'Automorphic' if num == str(n * n)[-len(num):] else 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		square = n * n
		while n > 0:
			if n % 10 != square % 10:
				return 'Not Automorphic'
			n //= 10
			square //= 10
		return 'Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		n2 = n ** 2
		str_n = str(n)
		str_n2 = str(n2)
		if str_n == str_n2[len(str_n2) - len(str_n):]:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


import math

class Solution:

	def is_AutomorphicNumber(self, n):
		s = pow(n, 2)
		s = str(s)
		n = str(n)
		if s.endswith(n):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = n
		n = n ** 2
		if a < 10:
			q = n % 10
		elif a < 100:
			q = n % 100
		elif a < 1000:
			q = n % 1000
		else:
			q = n % 10000
		if q == a:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		k = str(n ** 2)
		k = k[::-1]
		k = k[:len(str(n))]
		k = k[::-1]
		if k == str(n):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		squared = int(n ** 2)
		if str(squared)[-len(str(n)):] == str(n):
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		s = n ** 2
		b = len(str(n))
		s = str(s)
		l = len(str(s))
		a = s[l - b:]
		if int(a) == n:
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sum = n ** 2
		n = str(n)
		count = 0
		b = ''
		c = 'Automorphic'
		d = 'Not Automorphic'
		while count < len(n):
			a = sum % 10
			b = str(a) + b
			count += 1
			sum = sum // 10
		if int(b) == int(n):
			return c
		else:
			return d


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n * n
		while n:
			if sq % 10 != n % 10:
				return 'Not Automorphic'
			n = n // 10
			sq = sq // 10
		return 'Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n * n
		temp = str(sq)
		dig = int(temp[-len(str(n)):])
		if dig == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		num_sqr = n ** 2
		str_num_sqr = str(num_sqr)
		str_num = str(n)
		if n == 0 or n == 1:
			return 'Automorphic'
		if str_num[::-1] == str_num_sqr[:len(str_num_sqr) - len(str_num) - 1:-1]:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		SQUARE_OF_NUMBER = n ** 2
		m = 'Automorphic'
		k = 'Not Automorphic'
		i = 0
		rem = 0
		sum = ''
		while i < len(str(n)):
			rem = SQUARE_OF_NUMBER % 10
			sum = sum + str(rem)
			SQUARE_OF_NUMBER = SQUARE_OF_NUMBER // 10
			i = i + 1
		if n == int(sum[::-1]):
			return m
		else:
			return k


class Solution:

	def is_AutomorphicNumber(self, n):
		square = n ** 2
		n = str(n)
		square = str(square)
		x = len(n)
		if square.endswith(n):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		nsqaure = n ** 2
		t = n
		count = 1
		while t > 0:
			count *= 10
			t //= 10
		if nsqaure % count == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = str(n)
		b = n * n
		c = str(b)
		if c.endswith(a):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		square = n * n
		mod = pow(10, len(str(n)))
		if square % mod == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n * n
		ns = str(n)
		s = str(sq)
		a = s[-len(ns):]
		if int(a) == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = n * n
		b = n
		count = 0
		while b > 0:
			if a % 10 == b % 10:
				count += 1
			a = a // 10
			b = b // 10
		if count == len(str(n)):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = n * n
		l = []
		l = list(map(str, str(n)))
		count = 0
		j = -1
		for i in range(len(l)):
			r = a % 10
			if r == int(l[j]):
				count += 1
			a = a // 10
			j -= 1
		if count == len(l):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		h = n * n
		a = len(str(n))
		v = 10 ** a
		if h % v == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = n * n
		g = len(str(n))
		l = 10 ** g
		if a % l == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = n ** 2
		b = len(str(n))
		d = 10 ** b
		if a % d == n:
			return 'Automorphic '
		else:
			return 'Not Automorphic'


import math

class Solution:

	def is_AutomorphicNumber(self, n):
		x = n * n
		s = n
		c = 0
		while n != 0:
			c += 1
			n = int(n / 10)
		y = pow(10, c)
		if x % y == s:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		squaredNum = n * n
		n2 = str(n)
		s2 = str(squaredNum)
		if s2.endswith(n2):
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		str1 = str(n)
		sq = str(n ** 2)
		y = sq[-len(str1):]
		if y == str1:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		(tn, dn, c) = (n * n, n, 0)
		while dn > 0:
			c += 1
			dn = dn // 10
		if tn % 10 ** c == n:
			return 'Automorphic'
		return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sqaure = pow(n, 2)
		if int(str(sqaure)[-len(str(n)):]) == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n ** 2
		l = len(str(n))
		return ['Not Automorphic', 'Automorphic'][str(sq)[-l:] == str(n)]


class Solution:

	def is_AutomorphicNumber(self, n):
		l = len(str(n))
		h = n ** 2
		b = h % 10 ** l
		if n == b:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		s = n * n
		flag = 0
		while n != 0:
			if n % 10 != s % 10:
				return 'Not Automorphic'
				flag = 1
				break
			n = n // 10
			s = s // 10
		if flag == 0:
			return 'Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		m = n ** 2
		f = len(str(n))
		if str(n) == str(m)[-f:]:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		d = len(str(n))
		c = n ** 2
		last = c % pow(10, d)
		if last == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		num_of_digits = len(str(n))
		square = n ** 2
		last = square % pow(10, num_of_digits)
		if last == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		c = str(n ** 2)
		if int(c[-len(str(n)):]) == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = str(n)
		l = len(a)
		b = str(n ** 2)
		c = len(b)
		if b[c - l:c] == a:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		a = str(n * n)
		b = str(n)
		if a[-len(b):] == b:
			return 'Automorphic'
		else:
			return 'Not Automorphic'


class Solution:

	def is_AutomorphicNumber(self, n):
		sq = n ** 2
		lst = ''
		num = len(str(n))
		while num > 0:
			temp = sq % 10
			lst = str(temp) + lst
			sq //= 10
			num -= 1
		if int(lst) == n:
			return 'Automorphic'
		else:
			return 'Not Automorphic'