Given a number N. Count the number of digits in N which evenly divides N.
Note :- Evenly divides means whether N is divisible by a digit i.e. leaves a remainder 0 when divided.
 
Example 1:
Input:
N = 12
Output:
2
Explanation:
1, 2 both divide 12 evenly
Example 2:
Input:
N = 23
Output
0
Explanation:
2 and 3, none of them
divide 23 evenly
Your Task:
You don't need to read input or print anything. Your task is to complete the function evenlyDivides() which takes an integer N as input parameters and returns an integer, total number factor of digits N which divides N evenly.
Expected Time Complexity: O(log N)
Expected Space Complexity: O(1)
 
Constraints:
1<=N<=10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: Number theory

Starter code: #User function Template for python3





class Solution:

    def evenlyDivides (self, N):

        # code here

Solutions:
class Solution:

	def evenlyDivides(self, N):
		a = N
		count = 0
		while a > 0:
			rem = int(a % 10)
			if rem > 0:
				if N % rem == 0:
					count = count + 1
			a = a / 10
		return count


class Solution:

	def evenlyDivides(self, N):
		a = [int(i) for i in str(N)]
		count = 0
		for j in a:
			if j != 0 and N % j == 0:
				count = count + 1
		return count


class Solution:

	def evenlyDivides(self, N):
		count = 0
		temp = N
		while temp != 0:
			d = temp % 10
			temp //= 10
			if d > 0 and N % d == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		n = str(N)
		count = 0
		for i in n:
			if int(i) == 0:
				continue
			elif N % int(i) == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		n = N
		ans = 0
		while n != 0:
			dig = n % 10
			if dig == 0:
				n = n // 10
				continue
			if N % dig == 0:
				ans += 1
			n = n // 10
		return ans


class Solution:

	def evenlyDivides(self, N):
		num = N
		count = 0
		while N != 0:
			rem = N % 10
			if rem != 0 and num % rem == 0:
				count += 1
			N = N // 10
		return count


class Solution:

	def evenlyDivides(self, N):
		dup = N
		count = 0
		while N != 0:
			d = N % 10
			if d != 0:
				if dup % d == 0:
					count += 1
			N = N // 10
		return count


class Solution:

	def evenlyDivides(self, N):
		s = 0
		for i in str(N):
			if i != '0' and N % int(i) == 0:
				s += 1
		return s


class Solution:

	def evenlyDivides(self, N):
		original = N
		count = 0
		while N:
			r = N % 10
			if r != 0 and original % r == 0:
				count += 1
			N //= 10
		return count


class Solution:

	def evenlyDivides(self, N):
		count = 0
		for digit in str(N):
			if digit != '0' and N % int(digit) == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		count = 0
		currNum = N
		currDigit = 0
		while currNum > 0:
			currDigit = currNum % 10
			currNum = currNum // 10
			if currDigit == 0:
				continue
			if N % currDigit == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		c = 0
		st = str(N)
		for i in range(len(st)):
			d = int(st[i])
			if d != 0 and N % d == 0:
				c += 1
		return c


class Solution:

	def evenlyDivides(self, N):
		length = len(str(N))
		string = str(N)
		counter = 0
		for i in range(length):
			digit = int(string[i])
			if digit != 0:
				if N % digit == 0:
					counter += 1
		return counter


class Solution:

	def evenlyDivides(self, N):
		count = 0
		s = [int(digit) for digit in str(N)]
		while 0 in s:
			s.remove(0)
		for i in range(len(s)):
			if N % s[i] == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		x = N
		count = 0
		while x > 0:
			digit = x % 10
			x //= 10
			if digit != 0:
				if N % digit == 0:
					count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		x = N
		c = 0
		while x > 0:
			if x % 10 != 0:
				if N % (x % 10) == 0:
					c += 1
			x //= 10
		return c


class Solution:

	def evenlyDivides(self, N):
		n_str_list = list(str(N))
		acum = 0
		for x in n_str_list:
			if not x == '0' and N % int(x) == 0:
				acum += 1
		return acum


class Solution:

	def evenlyDivides(self, n):
		count = 0
		num = str(n)
		li = [int(x) for x in num]
		for i in li:
			if i != 0 and n % i == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		c = 0
		a = str(N)
		for i in a:
			digit = int(i)
			if digit != 0 and N % digit == 0:
				c += 1
		return c


class Solution:

	def evenlyDivides(self, N):
		count = 0
		for i in str(N):
			if int(i) % 10 == 0 or N % int(i) != 0:
				continue
			count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		res = 0
		check = N
		while N != 0:
			if N % 10 != 0 and check % (N % 10) == 0:
				res += 1
			N = N // 10
		return res


class Solution:

	def evenlyDivides(self, N):
		temp = str(N)
		cnt = 0
		for i in temp:
			if int(i):
				if not N % int(i):
					cnt += 1
		return cnt


class Solution:

	def evenlyDivides(self, n):
		count = 0
		temp = n
		while temp > 0:
			r = temp % 10
			if r != 0 and n % r == 0:
				count += 1
			temp //= 10
		return count


class Solution:

	def evenlyDivides(self, N):
		real_num = N
		c = 0
		while N != 0:
			d = N % 10
			if d != 0:
				if real_num % d == 0:
					c += 1
			N = N // 10
		return c


class Solution:

	def evenlyDivides(self, N):
		count = 0
		word = [x for x in str(N) if x != '0']
		for i in word:
			if N % int(i) == 0:
				count += 1
		return count


class Solution:

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


class Solution:

	def evenlyDivides(self, N):
		nLen = len(str(N))
		strN = str(N)
		count = 0
		for i in range(nLen):
			d = int(strN[i])
			if d != 0:
				if N % d == 0:
					count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		count = 0
		num = list(map(int, str(N)))
		for i in num:
			if i != 0 and N % i == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		count = 0
		result = N
		while N > 0:
			digit = N % 10
			if digit > 0 and result % digit == 0:
				count += 1
			N = N // 10
		return count


import sys

class Solution:

	def evenlyDivides(self, N):
		count = 0
		n = str(N)
		for i in n:
			try:
				if N % int(i) == 0:
					count += 1
			except ZeroDivisionError:
				pass
		return count


class Solution:

	def evenlyDivides(self, N):
		s = 0
		n = N
		l = []
		while N != 0:
			x = N % 10
			N = N // 10
			l.append(x)
		for i in l:
			if i > 0 and n % i == 0:
				s += 1
		return s


class Solution:

	def evenlyDivides(self, N):
		no = N
		cnt = 0
		while N > 0:
			a = N % 10
			if a != 0 and no % a == 0:
				cnt += 1
			N //= 10
		return cnt


class Solution:

	def evenlyDivides(self, N):
		l = []
		s = 0
		if N <= 9:
			return 1
		else:
			x = N
			while x > 9:
				a = x % 10
				l.append(a)
				x = x // 10
			l.append(x)
			l = [i for i in l if i != 0]
			for i in l:
				if N % i == 0:
					s += 1
		return s


class Solution:

	def evenlyDivides(self, N):
		counter = 0
		for i in str(N):
			if i == '0':
				continue
			if N % int(i) == 0:
				counter = counter + 1
		return counter


class Solution:

	def evenlyDivides(self, N):
		total = 0
		a = N
		while N > 0:
			rem = N % 10
			N = N // 10
			if rem > 0 and a % rem == 0:
				total += 1
		return total


class Solution:

	def evenlyDivides(self, N):
		c = 0
		rem = N
		Nstring = str(N)
		for i in Nstring:
			if int(i) == 0:
				continue
			elif N % int(i) == 0:
				c += 1
		return c


class Solution:

	def evenlyDivides(self, n):
		p = n
		cnt = 0
		while p > 0:
			c = p % 10
			p //= 10
			if c == 0:
				continue
			elif n % c == 0:
				cnt += 1
		return cnt


class Solution:

	def evenlyDivides(self, N):
		count = 0
		for i in range(0, len(str(N))):
			if int(str(N)[i]) > 0 and N % int(str(N)[i]) == 0:
				count = count + 1
		return count


203

class Solution:

	def evenlyDivides(self, N):
		StN = N
		count = 0
		while N > 0:
			rem = N % 10
			if rem is not 0 and StN % rem is 0:
				count += 1
			N //= 10
		return count


class Solution:

	def evenlyDivides(self, N):
		n = 0
		t = N
		while N != 0:
			t1 = N % 10
			N = N // 10
			if t1 == 0:
				continue
			if t % t1 == 0:
				n += 1
		return n


class Solution:

	def evenlyDivides(self, N):
		c = N
		count = 0
		while c != 0:
			b = c % 10
			if b > 0 and N % b == 0:
				count += 1
			c = c // 10
		return count


class Solution:

	def evenlyDivides(self, N):
		a = str(N)
		result = 0
		for x in a:
			if x != '0' and N % int(x) == 0:
				result += 1
		return result


class Solution:

	def evenlyDivides(self, N):
		n = N
		temp = n
		c = 0
		while n != 0:
			digit = n % 10
			if digit > 0:
				if temp % digit == 0:
					c = c + 1
			n = n // 10
		return c


class Solution:

	def evenlyDivides(self, N):
		c = 0
		t = N
		while t > 0:
			d = t % 10
			if d > 0 and N % d == 0:
				c = c + 1
			t = t // 10
		return c


class Solution:

	def evenlyDivides(self, N):
		str_n = str(N)
		list_n = list(str_n)
		l = []
		new_l = list(filter(lambda x: x != '0', list_n))
		for i in new_l:
			if N % int(i) == 0:
				l.append(i)
			else:
				continue
		if len(l) == 0:
			return 0
		else:
			return len(l)


class Solution:

	def evenlyDivides(self, N):
		x = str(N)
		num = 0
		for i in range(len(x)):
			if x[i] == '0':
				pass
			elif N % int(x[i]) == 0:
				num += 1
		return num


class Solution:

	def evenlyDivides(self, N):
		M = str(N)
		count = 0
		for i in range(0, len(M)):
			if int(M[i]) == 0:
				pass
			elif N % int(M[i]) == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		ans = N
		count = 0
		bool1 = True
		for i in str(N):
			if int(i) == 0:
				continue
			if N % int(i) != 0:
				continue
			count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		n1 = N
		(c, k) = (0, 0)
		while N:
			k = N % 10
			N = N // 10
			if k == 0:
				continue
			elif n1 % k == 0:
				c += 1
		return c


class Solution:

	def evenlyDivides(self, N):
		count = 0
		main = N
		while N > 0:
			lastDigit = N % 10
			N = N // 10
			if lastDigit != 0:
				if main % lastDigit == 0:
					count += 1
		return count


class Solution:

	def evenlyDivides(self, n):
		count = 0
		temp = n
		while temp != 0:
			quo = temp % 10
			temp = temp // 10
			if quo != 0:
				if n % quo == 0:
					count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		Num = N
		count = 0
		while N != 0:
			d = N % 10
			N = N // 10
			if d == 0:
				pass
			elif Num % d == 0:
				count += 1
		return count


class Solution:

	def evenlyDivides(self, N):
		count = 0
		number = N
		while number > 0:
			remember = number % 10
			if remember > 0:
				if N % remember == 0:
					count += 1
			number = number // 10
		return count


class Solution:

	def evenlyDivides(self, N):
		c = 0
		m = N
		while m > 0:
			if m % 10 != 0 and N % (m % 10) == 0:
				c += 1
			m = m // 10
		return c


class Solution:

	def evenlyDivides(self, num):
		count = 0
		temp = num
		while temp > 0:
			rem = temp % 10
			if rem == 0:
				count += 0
			elif num % rem == 0:
				count += 1
			temp = temp // 10
		return count


class Solution:

	def evenlyDivides(self, N):
		a = N
		count = 0
		while N != 0:
			if N % 10 != 0 and a % (N % 10) == 0:
				count += 1
				N //= 10
			else:
				N //= 10
		return count


class Solution:

	def evenlyDivides(self, N):
		temp = N
		result = 0
		while temp > 0:
			rem = temp % 10
			if rem != 0 and N % rem == 0:
				result = result + 1
			temp = int(temp / 10)
		return result


class Solution:

	def evenlyDivides(self, N):
		c = 0
		p = str(N)
		for i in range(len(p)):
			if p[i] == '0':
				continue
			if N % int(p[i]) == 0:
				c += 1
		return c


class Solution:

	def evenlyDivides(self, N):
		cnt = 0
		x = str(N)
		for i in range(0, len(x)):
			y = int(x[i])
			if y != 0 and N % y == 0:
				cnt += 1
		return cnt