Given a number N. Check whether it is divisible by the sum of its digits or not.
Example 1:
Input:
N=18
Output:
1
Explanation:
The sum of digits of 18 is 1+8=9 
which divides 18.so, answer is 1.
Example 2:
Input:
N=25
Output:
0
Explanation:
The sum of digits of 25 is 2+5=7 which does
not divide 25, so answer is 0.
Your Task:
You don't need to read input or print anything.Your task is to complete the function isDivisible() which takes the number N as input parameter and returns 1 if it is divisible by its digit sum.Otherwise,it returns 0.
Expected Time Complexity:O(LogN)
Expected Auxillary Space:O(1)
Constraints:
1<=N<=10^{9}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(LogN)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def isDivisible(self,N):
        #code here

Solutions:
class Solution:

	def isDivisible(self, N):
		s = 0
		x = N
		while N != 0:
			d = N % 10
			s = s + d
			N = N // 10
		if x % s == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		summ = 0
		for i in str(N):
			summ += int(i)
		if N % summ == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		lis = [int(x) for x in str(N)]
		sum1 = sum(lis)
		if N % sum1 == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		m = str(N)
		s = 0
		for i in m:
			s += int(i)
		if N % s == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		string = str(N)
		divisor = 0
		divisor = sum((divisor + int(string[i]) for i in range(len(string))))
		return 1 if N % divisor == 0 else 0


class Solution:

	def isDivisible(self, N):
		temp = N
		s = 0
		while N != 0:
			r = N % 10
			s = s + r
			N = N // 10
		if temp % s == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		p = str(N)
		a = [int(i) for i in p]
		k = sum(a)
		if N % k == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		sum = 0
		ans = str(N)
		for i in ans:
			sum = sum + int(i)
		if N % sum == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		s = 0
		n = N
		while N > 0:
			r = N % 10
			s += r
			N = N // 10
		if n % s == 0:
			return 1
		return 0


class Solution:

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


class Solution:

	def isDivisible(self, N):
		sum = 0
		z = N
		while N > 0:
			sum = sum + N % 10
			N //= 10
		if z % sum == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		s = str(N)
		k = 0
		i = 0
		while i < len(s):
			p = s[i]
			i = i + 1
			k = k + int(p)
		if N % k == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		temp = N
		l = []
		while N:
			rem = N % 10
			N = N // 10
			l.append(rem)
		if temp % sum(l) == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		a = list(str(N))
		m = list(map(int, a))
		if N % sum(m) == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		sm = sum(map(int, str(N)))
		return 1 if N % sm == 0 else 0


class Solution:

	def isDivisible(self, N):
		a = N
		s = 0
		while N > 0:
			rem = N % 10
			s += rem
			N = N // 10
		if a % s == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		(res, x) = (0, str(N))
		for i in x:
			res += int(i)
		return 1 if N % res == 0 else 0


class Solution:

	def isDivisible(self, N):
		arr = list(str(N))
		ans = 0
		for e in arr:
			ans = ans + int(e)
		if N % ans == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		temp = N
		sum = 0
		while N:
			d = N % 10
			sum += d
			N //= 10
		if temp % sum == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		N1 = N
		sum = 0
		while N1 > 0:
			rem = N1 % 10
			sum = sum + rem
			N1 = N1 // 10
		if N % sum == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		n = N
		sm = 0
		while N > 0:
			sm += N % 10
			N //= 10
		return int(n % sm == 0)


class Solution:

	def isDivisible(self, N):
		t = 0
		h = N
		while N != 0:
			k = N % 10
			t += k
			N = N // 10
		if h % t == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		sum1 = 0
		a = str(N)
		for i in a:
			sum1 = sum1 + int(i)
		if N % sum1 != 0:
			return '0'
		else:
			return '1'


class Solution:

	def isDivisible(self, N):
		m = N
		sum = 0
		while N > 0:
			sum += N % 10
			N = int(N / 10)
		if m % sum == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		k = sum(list(map(lambda x: int(x), str(N))))
		return 1 if N % k == 0 else 0


class Solution:

	def isDivisible(self, N):
		sum = 0
		for i in str(N):
			sum = sum + int(i)
		if N % sum == 0:
			return 1
		return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isDivisible(N))


class Solution:

	def isDivisible(self, N):
		s = 0
		t = N
		while N:
			r = N % 10
			s += r
			N = N // 10
		if t % s == 0:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isDivisible(N))


class Solution:

	def isDivisible(self, N):
		s = 0
		k = [int(d) for d in str(N)]
		for i in k:
			s = s + i
		if N % s == 0:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isDivisible(N))


class Solution:

	def isDivisible(self, N):
		o = N
		l = []
		while N != 0:
			r = N % 10
			l.append(r)
			N = N // 10
		k = sum(l)
		if o % k == 0:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isDivisible(N))


class Solution:

	def isDivisible(self, N):
		digits = str(N)
		sum_digits = 0
		for digit in digits:
			sum_digits += int(digit)
		if N % sum_digits == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		self.sum = 0
		self.num = N
		while self.num > 0:
			self.rem = self.num % 10
			self.sum += self.rem
			self.num = self.num // 10
		if N % self.sum == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, n):
		ns = str(n)
		total = 0
		for i in range(len(ns)):
			total += ord(ns[i]) - ord('0')
		if n % total == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, n):
		res = 0
		n = str(n)
		for val in n:
			res += int(val)
		if int(n) % res == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		copy = N
		s = 0
		while N:
			s += N % 10
			N = N // 10
		if copy % s == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		s = [int(i) for i in str(N)]
		return 1 if N % sum(s) == 0 else 0


class Solution:

	def isDivisible(self, N):
		st = str(N)
		arr = []
		for i in st:
			arr.append(int(i))
		ans = sum(arr)
		if N % ans == 0:
			return '1'
		else:
			return '0'


class Solution:

	def isDivisible(self, N):
		a = list(str(N))
		t = 0
		for i in range(len(a)):
			t += int(a[i])
		if N % t == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		p = N
		if N % self.digitsum(p) == 0:
			return 1
		return 0

	def digitsum(self, n):
		d = 0
		s = 0
		while n != 0:
			d = n % 10
			s = s + d
			n = n // 10
		return s


class Solution:

	def isDivisible(self, N):
		digit_sum = 0
		rem = 0
		cur = N
		while cur != 0:
			rem = cur % 10
			digit_sum += rem
			cur = cur - rem
			cur /= 10
		return 1 if N % digit_sum == 0 else 0


class Solution:

	def isDivisible(self, N):
		su = 0
		k = [int(d) for d in str(N)]
		for i in k:
			su = su + i
		if N % su == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		summ = sum((int(x) for x in str(N)))
		if N % summ == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		total = 0
		for i in list(map(lambda _: int(_), str(N))):
			total += i
		if N % total == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		Sum = 0
		n = N
		while n != 0:
			a = n % 10
			n = n // 10
			Sum = Sum + a
		if N % Sum == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		sum_d = 0
		n = N
		while n > 0:
			sum_d += n % 10
			n = n // 10
		if N % sum_d == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		X = str(N)
		l = [int(i) for i in X]
		sm = sum(l)
		if N % sm == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		n = len(str(N))
		total = 0
		nn = str(N)
		for i in range(n):
			total = total + int(nn[i])
		if N % total == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		num_list = []
		sum = 0
		for n in str(N):
			num_list.append(n)
		for i in range(len(num_list)):
			sum += int(num_list[i])
		if N % sum == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		C = N
		sum1 = 0
		while N > 0:
			a = N % 10
			sum1 = sum1 + a
			N = N // 10
		if C % sum1 == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		result = 0
		rem = 0
		res = N
		for i in range(len(str(N))):
			rem = N % 10
			N = N // 10
			result = result + rem
		if res % result == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		n = N
		sum = 0
		for n1 in str(N):
			sum += int(n1)
		if n % sum == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		n = str(N)
		n = list(n)
		x = 0
		for num in n:
			x = x + int(num)
		if N % x == 0:
			return 1
		return 0


def sumdig(x):
	sum = 0
	while x > 0:
		sum += x % 10
		x = x // 10
	return sum

class Solution:

	def isDivisible(self, N):
		if N % sumdig(N) == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		h = 0
		b = N
		a = N
		while N != 0:
			b = N % 10
			h = h + b
			N = N // 10
		if a % h == 0:
			return 1
		else:
			return 0


class Solution:

	def isDivisible(self, N):
		temp = N
		temp_sum = 0
		while temp > 0:
			temp_sum += temp % 10
			temp //= 10
		return 1 if N % temp_sum == 0 else 0


class Solution:

	def isDivisible(self, N):
		num = N
		temp = 0
		while N > 0:
			temp += N % 10
			N = N // 10
		if num % temp == 0:
			return 1
		return 0


class Solution:

	def isDivisible(self, N):
		temp = N
		sod = 0
		while N != 0:
			r = N % 10
			sod += r
			N = N // 10
		return int(temp % sod == 0)