A x digit number n is called Keith number if it appears in a special sequence (defined below) generated using its digits. The special sequence has first x terms as digits of n and other terms are recursively evaluated as sum of previous x terms.The task is to find if a given number is Keith Number or not.
Example 1:
Input: n = 197
Output: 1 
Explanation: 197 has 3 digits, so n = 3 
The number is Keith because it appears 
in the special sequence that has first
three terms as 1, 9, 7 and remaining
terms evaluated using sum of previous 3
terms. 1, 9, 7, 17, 33, 57, 107, 197, ..... 
Example 2:
Input: n = 12
Output: 0
Explanation: The number is not Keith 
because it doesn't appear in the special 
sequence generated using its digits. 
1, 2, 3, 5, 8, 13, 21, ..... 
Your Task:  
You dont need to read input or print anything. Complete the function isKeith() which takes n as input parameter and returns 1 if a given number is Keith Number else returns 0.
Expected Time Complexity: O(n*k)
Expected Auxiliary Space: O(n)
Constraints:
1<= n <=10^{4}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:

    def isKeith (self, n):

        # code here 

Solutions:
class Solution:

	def isKeith(self, n):
		x = len(str(n))
		k = []
		for i in str(n):
			k.append(int(i))
		k.append(sum(k))
		i = x + 1
		while k[i - 1] < n:
			k.append(2 * k[i - 1] - k[i - x - 1])
			i = i + 1
		if k[i - 1] == n:
			return 1
		else:
			return 0


class Solution:

	def isKeith(self, n):
		(l, x, m, a) = ([], 0, n, 0)
		while m:
			l.append(m % 10)
			m //= 10
			x += 1
		l = l[::-1]
		while a < n:
			a = sum(l)
			del l[0]
			l.append(a)
		if a == n:
			return 1
		return 0


class Solution:

	def isKeith(self, n):
		seq = [int(i) for i in str(n)]
		k = len(seq)
		i = 0
		while sum(seq[i:i + k]) <= n:
			seq += [sum(seq[i:i + k])]
			i += 1
		if seq[-1] == n:
			return 1
		else:
			return 0


class Solution:

	def isKeith(self, n: int) -> int:
		digits = self.findDigits(n)
		i = len(digits)
		while True:
			number = sum(digits[-i:])
			if number == n:
				return 1
			elif number > n:
				return 0
			else:
				digits.append(number)

	@staticmethod
	def findDigits(N: int) -> list:
		result = []
		while N:
			result.append(N % 10)
			N //= 10
		result.reverse()
		return result


class Solution:

	def isKeith(self, n):
		b = n
		n = str(n)
		n1 = list(n)
		i = 0
		s = 0
		while s < b:
			s = 0
			a = len(n)
			while a != 0:
				s = s + int(n1[i])
				i = i + 1
				a = a - 1
			i = i - (len(n) - 1)
			n1.append(s)
		if n1[len(n1) - 1] == int(n):
			return 1
		return 0


class Solution:

	def isKeith(self, n):
		l = []
		b = n
		while n != 0:
			l.append(n % 10)
			n = n // 10
		s = sum(l)
		l = l[::-1]
		i = 0
		while l[-1] < b:
			l.append(s)
			s = s + l[-1] - l[i]
			i += 1
		if l[-1] == b:
			return 1
		return 0


class Solution:

	def isKeith(self, n):
		a = []
		f = str(n)
		h = len(f)
		s = 0
		for i in range(len(f)):
			a.append(int(f[i]))
		m = h
		while a[m - 1] <= n:
			for i in range(1, h + 1):
				s = s + a[m - i]
			a.append(s)
			s = 0
			m = m + 1
		if a[m - 2] == n:
			return 1
		else:
			return 0


class Solution:

	def isKeith(self, n):
		N = str(n)
		l = len(N)
		arr = []
		for y in range(l):
			arr.append(int(N[y]))
		x = 0
		sm = 0
		while sm < n:
			arr.append(sum(arr[x:l + x]))
			sm = sum(arr[x:l + x])
			x += 1
		if n in arr:
			return 1
		else:
			return 0


class Solution:

	def isKeith(self, n):
		a = [int(x) for x in str(n)]
		while a[len(a) - 1] < n:
			a.append(sum(a))
			a.pop(0)
		if a[len(a) - 1] == n:
			return 1
		return 0