Strong Numbers are the numbers whose sum of factorial of digits is equal to the original number. Given a number, the task is to check if it is a Strong Number or not.
 
Example 1:
Input: 145
Output: 1
Explanation: 1! + 4! + 5! = 145
Example 2:
Input: 5314
Output: 0
Explanation: 5! + 3! + 1! + 4! 
is not equal to 5314.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function is_StrongNumber() which takes the number as input parameter and returns 1 if it is Strong Number otherwise returns 0.
 
Expected Time Complexity : O(Number of digits in N)
Expected Space Complexity: O(1)
 
Constraints:
1 <= n <= 10000

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(Number of digits in N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
	def is_StrongNumber(self, n):
		# Code here

Solutions:
class Solution:

	def is_StrongNumber(self, n):

		def fact(x):
			if x == 1 or x == 0:
				return 1
			return x * fact(x - 1)
		sumo = 0
		m = n
		while n != 0:
			r = n % 10
			n = n // 10
			sumo = sumo + fact(r)
		if sumo == m:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):

		def f(x):
			s = 1
			for i in range(1, x + 1):
				s = s * i
			return s
		c = n
		b = 0
		while n != 0:
			d = n % 10
			b = b + f(d)
			n = n // 10
		if c == b:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		sumi = 0
		a = n
		while n > 0:
			rem = n % 10
			fact = 1
			for i in range(1, rem + 1):
				fact *= i
			sumi += fact
			n //= 10
		if sumi == a:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		s = 0
		rr = n
		while n != 0:
			f = 1
			r = n % 10
			for i in range(1, r + 1):
				f *= i
			s += f
			n //= 10
		if s == rr:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		m = n
		s = 0
		p = str(n)
		for i in range(len(p)):
			x = n % 10
			s += math.factorial(x)
			n = n // 10
		if s == m:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		a = n
		summ = 0
		while a > 0:
			b = a % 10
			a = int(a / 10)
			f = 1
			for i in range(1, b + 1):
				f = f * i
			summ += f
		if summ == n:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		sum = 0
		mstr = str(n)
		for num in mstr:
			sum += math.factorial(int(num))
		return 1 if n == sum else 0


from math import factorial

class Solution:

	def is_StrongNumber(self, n):
		res = 0
		original_num = n
		while n:
			temp = n % 10
			n = n // 10
			res += factorial(temp)
		if res == original_num:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		c = n
		while n != 0:
			rem = n % 10
			fac = 1
			for i in range(rem, 1, -1):
				fac *= i
			c -= fac
			n = n // 10
		if n == c:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		m = n
		s = 0

		def digit(n):
			c = 0
			while n > 0:
				n = n // 10
				c += 1
			return c
		for i in range(digit(n)):
			x = n % 10
			s += math.factorial(x)
			n = n // 10
		if s == m:
			return 1
		else:
			return 0


from math import factorial

class Solution:

	def is_StrongNumber(self, n):
		p = n
		s = 0
		while n != 0:
			r = n % 10
			s = s + factorial(r)
			n = n // 10
		if p == s:
			c = 1
		else:
			c = 0
		return c


class Solution:

	def is_StrongNumber(self, n):

		def fact(s):
			f = 1
			for i in range(1, s + 1):
				f = f * i
			return f
		f = 0
		s = str(n)
		for i in s:
			j = int(i)
			f = f + fact(j)
		if f == n:
			return 1
		else:
			return 0


from math import factorial

class Solution:

	def is_StrongNumber(self, n):
		N = n
		sum = 0
		while n != 0:
			rem = n % 10
			sum += factorial(rem)
			n //= 10
		if sum == N:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		num = n
		sum1 = 0

		def fact(N):
			product = 1
			for i in range(2, N + 1):
				product *= i
			return product
		while n != 0:
			remainder = n % 10
			sum1 += fact(remainder)
			n //= 10
		if sum1 == num:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		temp = n

		def fact(k):
			s = 1
			for i in range(1, k + 1):
				s *= i
			return s
		res = 0
		while n > 0:
			a = n % 10
			res = res + fact(a)
			n //= 10
		if temp == res:
			return 1
		else:
			return 0


def fact(n):
	if n == 0:
		return 1
	return n * fact(n - 1)

class Solution:

	def is_StrongNumber(self, n):
		N = n
		s = 0
		while n:
			dig = n % 10
			s += fact(dig)
			n //= 10
		return int(s == N)


class Solution:

	def is_StrongNumber(self, n):
		temp = n
		result = 0
		while temp > 0:
			rem = temp % 10
			fact = 1
			for i in range(1, rem + 1):
				fact = fact * i
			result += fact
			temp = temp // 10
		if n == result:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):

		def fact(n):
			if n in [0, 1]:
				return 1
			else:
				return n * fact(n - 1)
		sum = 0
		for i in str(n):
			sum += fact(int(i))
		if sum == n:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		ip = n

		def factorial(a):
			f = 1
			for i in range(1, a + 1):
				f *= i
			return f
		x = 0
		while n != 0:
			d = n % 10
			x += factorial(d)
			n //= 10
		if ip == x:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		strong = n
		sum = 0
		while n > 0:
			r = n % 10
			fact = 1
			for i in range(1, r + 1):
				fact = fact * i
			sum = sum + fact
			n = n // 10
		if sum == strong:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, N):
		import math
		s = str(N)
		d = [math.factorial(int(x)) for x in s]
		d = sum(d)
		if d == N:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		x = n
		y = 0
		while x != 0:
			rem = x % 10
			y = y + math.factorial(rem)
			x = x // 10
		if n == y:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		l = []
		s = 0
		temp = n
		while n > 0:
			rem = n % 10
			l.append(rem)
			n = n // 10
		for i in l:
			s = s + math.factorial(i)
		if s == temp:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		N = n
		sum = 0
		while n > 0:
			r = n % 10
			f = math.factorial(r)
			sum = sum + f
			n = n // 10
		if sum == N:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		h = n
		s = 0
		while n > 0:
			r = n % 10
			f = math.factorial(r)
			s += f
			n = n // 10
		if s == h:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		m = str(n)
		c = 0
		for i in m:
			k = int(i)
			fact = 1
			for j in range(1, k + 1):
				fact = fact * j
			c = c + fact
		if n == c:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		c = []
		for i in str(n):
			p = 1
			for j in range(1, int(i) + 1):
				p *= j
			c.append(p)
		if sum(c) == n:
			return 1
		return 0


import math

class Solution:

	def is_StrongNumber(self, N):
		a = []
		n = [int(i) for i in str(N)]
		for i in n:
			a.append(math.factorial(i))
		return '1' if sum(a) == N else '0'


import math

class Solution:

	def is_StrongNumber(self, n):
		sum1 = 0
		x = n
		while x > 0:
			r = x % 10
			sum1 += math.factorial(r)
			x = x // 10
		if sum1 == n:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		import math as m
		n = str(n)
		a = 0
		for i in n:
			a += m.factorial(int(i))
		if a == int(n):
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		k = 0
		m = str(n)
		for i in m:
			h = 1
			while int(i) > 1:
				h = h * int(i)
				i = int(i) - 1
			k = k + h
		if k == n:
			return 1
		else:
			return 0


from math import factorial

class Solution:

	def is_StrongNumber(self, n):
		s = 0
		for i in str(n):
			s += factorial(int(i))
		return 1 if s == n else 0


def fact(n):
	c = 1
	while n >= 1:
		c *= n
		n = n - 1
	return c

class Solution:

	def is_StrongNumber(self, n):
		k = n
		p = 0
		while n > 0:
			r = n % 10
			p = p + fact(r)
			n = n // 10
		if p == k:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		sum = 0
		a = n
		while a:
			r = a % 10
			s = math.factorial(r)
			sum = sum + s
			a = a // 10
		if sum == n:
			return '1'
		else:
			return '0'


class Solution:

	def is_StrongNumber(self, n):
		Sum = 0
		N = n
		while N > 0:
			m = N % 10
			p = 1
			while m > 1:
				p = p * m
				m -= 1
			Sum = Sum + p
			N = N // 10
		if Sum == n:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		temp = n
		sum = 0
		while temp:
			i = 1
			fact = 1
			number = temp % 10
			while number >= i:
				fact = fact * i
				i = i + 1
			sum += fact
			temp = temp // 10
		if sum == n:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		sum = 0
		string = str(n)
		for i in string:
			sum = sum + math.factorial(int(i))
		if sum == n:
			return 1
		else:
			return 0


def factorial(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
	return ans

class Solution:

	def is_StrongNumber(self, n):
		s = str(n)
		ans = 0
		for i in s:
			ans += factorial(int(i))
		if ans == n:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		s = 0
		t = n
		while n:
			i = 1
			f = 1
			r = n % 10
			while i <= r:
				f = f * i
				i = i + 1
			s = s + f
			n = n // 10
		if s == t:
			return '1'
		else:
			return '0'


import math

class Solution:

	def is_StrongNumber(self, n):
		(s, dn) = (0, n)
		while dn != 0:
			s += math.factorial(dn % 10)
			dn = dn // 10
		if s == n:
			return 1
		return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		temp = n
		sum = 0
		while temp != 0:
			sum += math.factorial(temp % 10)
			temp = temp // 10
		if sum == n:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		sum = 0
		z = n
		while z > 0:
			dig = z % 10
			fac = 1
			for i in range(dig, 0, -1):
				fac *= i
			sum += fac
			z //= 10
		if sum == n:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		a = []
		x = list(str(n))
		for i in x:
			b = 1
			for j in range(1, int(i) + 1):
				b *= int(j)
			a.append(b)
		if sum(a) == n:
			return 1
		else:
			return 0


from math import factorial as f

class Solution:

	def is_StrongNumber(self, n):
		return [0, 1][sum([f(int(x)) for x in str(n)]) == n]


class Solution:

	def is_StrongNumber(self, n):
		s = str(n)
		su = 0
		for i in s:
			p = 1
			i = int(i)
			for j in range(1, i + 1):
				p = p * j
			su = su + p
		if su == n:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		temp = n
		sum = 0
		while n > 0:
			a = n % 10
			fact = 1
			for i in range(1, a + 1):
				fact = fact * i
			sum = sum + fact
			n = n // 10
		if sum == temp:
			return 1
		else:
			return 0


def fact(i):
	pd = 1
	for j in range(1, i + 1):
		pd *= j
	return pd

class Solution:

	def is_StrongNumber(self, n):
		temp = n
		sum1 = 0
		while n > 0:
			d = n % 10
			sum1 += fact(d)
			n //= 10
		if sum1 == temp:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):

		def fact(n):
			if n == 0 or n == 1:
				return 1
			return n * fact(n - 1)
		N = str(n)
		x = 0
		for i in N:
			x += fact(int(i))
		if x == n:
			return 1
		return 0


def factorial(n):
	if n == 0 or n == 1:
		return 1
	return n * factorial(n - 1)

class Solution:

	def is_StrongNumber(self, n):
		dup = n
		sum = 0
		while n != 0:
			f = n % 10
			sum += factorial(f)
			n = n // 10
		if sum == dup:
			return 1
		return 0


class Solution:

	def fact(self, N):
		if N == 1 or N == 0:
			return 1
		else:
			return N * self.fact(N - 1)

	def is_StrongNumber(self, n):
		a = str(n)
		l = []
		suma = 0
		for i in range(len(a)):
			l.append(self.fact(int(a[i])))
		for i in range(len(l)):
			suma += l[i]
		if n == suma:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):

		def fact(n):
			if n == 1 or n == 0:
				return 1
			else:
				return n * fact(n - 1)
		res = 0
		for x in str(n):
			res += fact(int(x))
		if res == n:
			return 1
		return 0


class Solution:

	def factorial(self, n):
		if n <= 1:
			return 1
		return n * self.factorial(n - 1)

	def sumFact(self, n):
		sm = 0
		while n > 0:
			sm += self.factorial(n % 10)
			n //= 10
		return sm

	def is_StrongNumber(self, n):
		return int(self.sumFact(n) == n)


class Solution:

	def is_StrongNumber(self, n):
		import math
		arr = list(str(n))
		ans = []
		for i in range(0, len(arr)):
			ans.append(math.factorial(int(arr[i])))
		ans = sum(ans)
		if n == ans:
			return 1
		else:
			return 0


def fact(n):
	if n == 0 or n == 1:
		return 1
	else:
		return n * fact(n - 1)

class Solution:

	def is_StrongNumber(self, n):
		s = 0
		p = n
		while n > 0:
			a = n % 10
			m = fact(a)
			s = s + m
			n = n // 10
		if s == p:
			return 1
		else:
			return 0


class Solution:

	def factorial(self, a):
		factor = 1
		if a == 0:
			return 1
		else:
			while a:
				factor = factor * a
				a -= 1
			return factor

	def is_StrongNumber(self, n):
		ans = 0
		number = n
		while n != 0:
			digit = n % 10
			n = n // 10
			ans += self.factorial(digit)
		if ans == number:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		temp = n
		sum = 0
		while n > 0:
			i = n % 10
			fac = 1
			if i == 0 or i == 1:
				fac = 1
			else:
				for j in range(1, i + 1):
					fac = fac * j
			sum = fac + sum
			n = n // 10
		if sum == temp:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		s = 0
		num = n
		while n > 0:
			digit = n % 10
			fact = 1
			for x in range(1, digit + 1):
				fact *= x
			s += fact
			n = n // 10
		if s == num:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		m = n
		s = 0
		while n > 0:
			x = n % 10
			s += math.factorial(x)
			n //= 10
		if m == s:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n: int) -> int:

		def factorial(num: int) -> int:
			result = 1
			for i in range(num, 1, -1):
				result *= i
			return result
		summation = 0
		number = n
		while number:
			summation += factorial(number % 10)
			number //= 10
		return 1 if summation == n else 0


import math

class Solution:

	def is_StrongNumber(self, n):
		sum = 0
		res = str(n)
		for i in range(len(res)):
			sum += math.factorial(int(res[i]))
		if sum == n:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):

		def fact(n):
			p = 1
			for i in range(1, n + 1):
				p *= i
			return p
		s = 0
		for i in str(n):
			s += fact(int(i))
		if s == n:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, N):
		s = 0
		r = 0
		num = N
		while num > 0:
			r = num % 10
			s = s + self.fact(r)
			num = num // 10
		if s == N:
			return 1
		return 0

	def fact(self, n):
		if n == 1 or n == 0:
			return 1
		f = self.fact(n - 1) * n
		return f


def fact(n):
	f = 1
	for i in range(1, n + 1):
		f = f * i
	return f

class Solution:

	def is_StrongNumber(self, n):
		t = n
		res = 0
		while n != 0:
			res += fact(n % 10)
			n = n // 10
		if res == t:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		m = n
		res = 0
		sum = 0
		while n:
			t = 1
			res = n % 10
			for i in range(1, res + 1):
				t *= i
			sum += t
			n = n // 10
		return 1 if m == sum else 0


class Solution:

	def is_StrongNumber(self, n):

		def fact(x):
			f = 1
			for i in range(1, x + 1):
				f = f * i
			return f
		S = n
		summ = 0
		while S > 0:
			x = int(S % 10)
			summ = summ + fact(x)
			S = int(S / 10)
		if summ == n:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, n):
		c = 0
		s = str(n)
		for ch in s:
			c += math.factorial(int(ch))
		if c == n:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		temp = n
		tot = 0
		while n != 0:
			fact = 1
			d = n % 10
			for i in range(1, d + 1):
				fact *= i
			tot += fact
			n //= 10
		if tot == temp:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		s = 0
		x = n

		def fact(N):
			if N == 0 or N == 1:
				return 1
			return N * fact(N - 1)
		while n:
			s += fact(n % 10)
			n = n // 10
		if s == x:
			return 1
		else:
			return 0


import math

class Solution:

	def is_StrongNumber(self, N):
		temp = N
		s = 0
		while N != 0:
			s += math.factorial(N % 10)
			N //= 10
		return 1 if temp == s else 0


class Solution:

	def is_StrongNumber(self, N):
		sum = 0
		M = N
		while N > 0:
			rem = N % 10
			pro = 1
			for i in range(1, rem + 1):
				pro *= i
			sum += pro
			N = int(N / 10)
		if sum == M:
			return 1
		return 0


class Solution:

	def is_StrongNumber(self, n):
		i = 0
		a = 0
		x = n
		while n > 0:
			w = 1
			s = n % 10
			n = n // 10
			for i in range(1, s + 1):
				w = w * i
			a = a + w
		if a == x:
			return 1
		else:
			return 0


class Solution:

	def is_StrongNumber(self, n):
		result = 0
		com = n
		while n > 0:
			temp = n // 10
			result += fac(n % 10)
			n = temp
		if result == com:
			return 1
		else:
			return 0

def fac(n):
	if n == 0:
		return n
	ans = 1
	for i in range(1, n + 1):
		ans *= i
	return ans