Given a number N.Check if it is Full Prime or not. 
Note : A full prime number is one in which the number itself is prime and all its digits are also prime.
Example 1:
Input:
N=31
Output:
0
Explanation:
N is prime but since 1 is not a 
prime so all the digits of N
are not prime.So, Answer is 0.
Example 2:
Input:
N=37
Output:
1
Explanation:
N is prime and so is all of its digits.
Thus, Answer is 1.
Your Task:
You don't need to read input or print anything.Your task is to complete the function fullPrime() which takes the number N as input parameter and returns 1 if the number is Full Prime.Otherwise return 0.
Expected Time Complexity:O(Sqrt(N))
Expected Auxillary Space:O(1)
Constraints:
1<=N<=10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Number theory

Starter code: #User function Template for python3

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

Solutions:
class Solution:

	def fullPrime(self, N):
		i = 2
		while i * i <= N:
			if N % i == 0:
				return 0
			i = i + 1
		while N > 0:
			if N % 10 != 2 and N % 10 != 3 and (N % 10 != 5) and (N % 10 != 7):
				return 0
			N //= 10
		return 1


class Solution:

	def fullPrime(self, N):
		if N == 1:
			return 0
		for i in range(2, int(N ** 0.5) + 1):
			if N % i == 0:
				return 0
		while N > 0:
			if N % 10 != 2 and N % 10 != 3 and (N % 10 != 5) and (N % 10 != 7):
				return 0
			N //= 10
		return 1


class Solution:

	def fullPrime(self, N):

		def prime(n):
			if n == 1 or n == 0:
				return False
			if n == 2:
				return True
			for i in range(2, int(n ** 0.5) + 1):
				if n % i == 0:
					return False
			return True
		if prime(N):
			while N != 0:
				r = N % 10
				if not prime(r):
					return 0
				N = N // 10
			return 1
		else:
			return 0


import math as m

class Solution:

	def prime_num(self, temp):
		if temp <= 1:
			return False
		for i in range(2, int(m.sqrt(temp)) + 1):
			if temp % i == 0:
				return False
		return True

	def fullPrime(self, n):
		if not self.prime_num(n):
			return '0'
		while n > 0:
			digit = n % 10
			if not self.prime_num(digit):
				return '0'
			n //= 10
		return '1'


import math

class Solution:

	def fullPrime(self, N):
		root = int(math.sqrt(N))
		for i in range(2, root + 1, 1):
			if N % i == 0:
				return 0
		N_str_list = list(str(N))
		for x in N_str_list:
			if x in '014689':
				return 0
		return 1


import math

class Solution:

	def isPrime(self, N):
		if N == 1 or N == 0:
			return 0
		for i in range(2, int(math.sqrt(N)) + 1):
			if N % i == 0:
				return False
		return True

	def fullPrime(self, N):
		if self.isPrime(N):
			while N > 0:
				if not self.isPrime(N % 10):
					return 0
				N //= 10
			return 1
		return 0


class Solution:

	def fullPrime(self, N):
		from math import sqrt

		def isPrime(n):
			if n <= 1:
				return False
			for i in range(2, int(sqrt(n)) + 1):
				if n % i == 0:
					return False
			return True
		l = list(str(N))
		if not isPrime(N):
			return 0
		else:
			for i in l:
				if not isPrime(int(i)):
					return 0
		return 1


class Solution:

	def fullPrime(self, N):
		lut = '2357'
		temp = str(N)
		for d in temp:
			if d not in lut:
				return 0
		for i in range(2, N // 2 + 1):
			if N % i == 0:
				return 0
		return 1


import math

def isprime(n):
	if n <= 1:
		return False
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

class Solution:

	def fullPrime(self, N):
		s = str(N)
		for i in s:
			if isprime(int(i)) == False:
				return 0
		if isprime(N):
			return 1
		else:
			return 0


import math

def fun(n):
	if n == 0 or n == 1:
		return False
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

class Solution:

	def fullPrime(self, N):
		if fun(N):
			s = str(N)
			c = 0
			for i in s:
				if fun(int(i)):
					c += 1
			if c == len(s):
				return 1
			return 0
		else:
			return 0


class Solution:

	def fullPrime(self, N):
		import math

		def is_prime(n):
			if n < 2:
				return False
			s = int(math.sqrt(n))
			for i in range(2, s + 1):
				if n % i == 0:
					return False
			return True
		s = str(N)
		l = list(map(int, s))
		c = 0
		for i in l:
			if is_prime(i) == 1 and is_prime(N) == 1:
				c += 1
		if c == len(l):
			return 1
		else:
			return 0


class Solution:

	def fullPrime(self, N):
		import math

		def is_prime(n):
			a = int(math.sqrt(n))
			if n < 2:
				return False
			for i in range(2, a + 1):
				if n % i == 0:
					return False
			return True
		if is_prime(N) == 0:
			return 0
		while N:
			d = N % 10
			N = N // 10
			if is_prime(d) == 0:
				return 0
		return 1


class Solution:

	def fullPrime(self, N):

		def is_prime(n):
			if n < 2:
				return 0
			else:
				import math
				x = int(math.sqrt(n))
				for i in range(2, x + 1):
					if n % i == 0:
						return 0
				else:
					return 1
		if is_prime(N) == 0:
			return 0
		while N:
			d = N % 10
			N = N // 10
			if is_prime(d) == 0:
				return 0
		return 1


import math

class Solution:

	def fullPrime(self, N):

		def prime(x):
			if x < 2:
				return False
			p = int(math.sqrt(x))
			for i in range(2, p + 1):
				if x % i == 0:
					return False
			return True
		c = 0
		if prime(N) == True:
			s = str(N)
			for i in s:
				if prime(int(i)) == True:
					c += 1
			if len(s) == c:
				return 1
			else:
				return 0
		else:
			return 0


class Solution:

	def fullPrime(self, N):

		def prime(n):
			if n == 0 or n == 1:
				return False
			for i in range(2, int(n ** 0.5) + 1):
				if n % i == 0:
					return False
			return True
		c = 0
		if prime(N):
			n = str(N)
			for i in n:
				if prime(int(i)):
					c += 1
			if c == len(n):
				return 1
		return 0


class Solution:

	def fullPrime(self, n):

		def isprime(n):
			if n <= 1:
				return False
			for i in range(2, int(n ** 0.5) + 1):
				if n % i == 0:
					return False
			return True
		c = 0
		if isprime(n):
			a = str(n)
			for i in a:
				if isprime(int(i)):
					c += 1
			if c == len(a):
				return 1
		return 0


class Solution:

	def fullPrime(self, n):

		def isprime(n):
			if n == 1:
				return False
			if n == 2 or n == 3:
				return True
			if n % 2 == 0 or n % 3 == 0:
				return False
			i = 5
			while i * i <= n:
				if n % i == 0 or n % (i + 2) == 0:
					return False
				i += 6
			return True
		if isprime(n):
			for i in str(n):
				if not isprime(int(i)):
					return 0
			return 1
		return 0


class Solution:

	def CheckPrime(self, N):
		if N == 0 or N == 1:
			return False
		if N == 2 or N == 3:
			return True
		for i in range(2, int(N ** 0.5) + 1):
			if N % i == 0:
				return False
		return True

	def fullPrime(self, N):
		if self.CheckPrime(N):
			while N > 0:
				a = N % 10
				if self.CheckPrime(a) == False:
					return 0
				N = N // 10
			return 1
		return 0


import math

class Solution:

	def fullPrime(self, N):

		def isprimes(N):
			if N <= 1:
				return False
			for i in range(2, int(math.sqrt(N) + 1)):
				if N % i == 0:
					return False
			return True
		k = 0
		c = [N]
		count = 0
		while N > 0:
			k = N % 10
			c.append(k)
			N = N // 10
		for i in c:
			if isprimes(i):
				count += 1
		if len(c) == count:
			return 1
		return 0


class Solution:

	def fullPrime(self, n):

		def prime(n):
			if n == 1 or n == 0:
				return False
			k = int(n ** 0.5)
			for i in range(2, k + 1):
				if n % i == 0:
					return False
			return True
		c = 0
		cou = 0
		N = n
		while n:
			d = n % 10
			if prime(d):
				c += 1
			cou += 1
			n = n // 10
		if c == cou and prime(N):
			return 1
		else:
			return 0


import math

def isprime(N):
	s = int(math.sqrt(N))
	if N <= 1:
		return False
	for i in range(2, s + 1):
		if N % i == 0:
			return False
	return True

class Solution:

	def fullPrime(self, N):
		l = []
		k = []
		if not isprime(N):
			return 0
		while N:
			r = N % 10
			l.append(r)
			N = N // 10
		for i in l:
			if not isprime(i):
				return 0
		return 1


import math

class Solution:

	def fullPrime(self, N):

		def isPrime(N):
			if N <= 1:
				return 0
			s = int(math.sqrt(N))
			for i in range(2, s + 1):
				if N % i == 0:
					return 0
			return 1
		if isPrime(N):
			while N != 0:
				d = N % 10
				if isPrime(d) == 0:
					return 0
				N = N // 10
		else:
			return 0
		return 1


class Solution:

	def fullPrime(self, N):
		if not self.isPrime(N):
			return 0
		while N > 0:
			digit = N % 10
			if not self.isPrime(digit):
				return 0
			N //= 10
		return 1

	def isPrime(self, num):
		if num < 2:
			return False
		if num == 2 or num == 3:
			return True
		if num % 2 == 0 or num % 3 == 0:
			return False
		for i in range(3, int(num ** 0.5) + 1, 2):
			if num % i == 0:
				return False
		return True


import math

class Solution:

	def fullPrime(self, N):

		def prime(c):
			if c < 2:
				return False
			for i in range(2, int(math.sqrt(c)) + 1):
				if c % i == 0:
					return False
			return True
		if prime(N):
			while N:
				x = N % 10
				if prime(x):
					pass
				else:
					return '0'
				N = N // 10
			return '1'
		else:
			return '0'


import math

class Solution:

	def fullPrime(self, N):

		def is_Prime(N):
			if N < 2:
				return False
			sq = int(math.sqrt(N))
			for i in range(2, sq + 1):
				if N % i == 0:
					return False
			return True
		if is_Prime(N):
			while N:
				a = N % 10
				N = N // 10
				if is_Prime(a):
					pass
				else:
					return '0'
			return '1'
		else:
			return '0'


class Solution:

	def fullPrime(self, N):
		s = int(N ** 0.5)
		if N == 1 or N == 0:
			return 1
		for i in range(2, s + 1):
			if N % i == 0:
				return 0
		for j in str(N):
			if int(j) == 1 or int(j) == 0:
				return 0
			for k in range(2, int(int(j) ** 0.5) + 1):
				if int(j) % k == 0:
					return 0
		return 1


import math

class Solution:

	def fullPrime(self, N):

		def isPrime(N):
			c = 0
			if N < 2:
				return False
			s = int(math.sqrt(N))
			for i in range(2, s + 1):
				if N % i == 0:
					c = c + 1
			if c == 0:
				return True
			else:
				return False
		a = str(N)
		k = []
		m = []
		for i in a:
			k.append(int(i))
		for j in k:
			if isPrime(j) == True:
				m.append(j)
		if len(m) == len(k) and isPrime(N) == True:
			return '1'
		else:
			return '0'


import math

def is_prime(n):
	if n < 2:
		return False
	s = int(math.sqrt(n))
	for j in range(2, s + 1):
		if n % j == 0:
			return False
	return True

class Solution:

	def fullPrime(self, N):
		lst = []
		c = 0
		k = N
		while k:
			x = k % 10
			k = k // 10
			lst.append(x)
		for i in lst:
			if is_prime(i) == False or is_prime(N) == False:
				c += 1
		if c != 0:
			return 0
		else:
			return 1


import math

class Solution:

	def fullPrime(self, N):

		def prime(n):
			if n <= 1:
				return False
			for i in range(2, int(math.sqrt(n)) + 1):
				if n % i == 0:
					return False
			return True
		c = 0
		m = [N]
		while N > 0:
			d = N % 10
			m.append(d)
			N = N // 10
		for i in range(len(m)):
			if prime(m[i]):
				c += 1
		if len(m) == c:
			return 1
		return 0


class Solution:

	def fullPrime(self, N):

		def isprime(N):
			if N < 2:
				return 0
			for i in range(2, int(N ** 0.5) + 1):
				if N % i == 0:
					return 0
			return 1
		if isprime(N):
			while N > 0:
				r = N % 10
				if isprime(r) == False:
					return 0
					break
				N = N // 10
			return 1
		else:
			return 0


from math import sqrt

class Solution:

	def fullPrime(self, N):

		def prime(a):
			a = int(a)
			if a < 2:
				return False
			for i in range(2, int(sqrt(a)) + 1):
				if a % i == 0:
					return False
			return True
		c = 0
		for j in str(N):
			if prime(j) == False:
				c += 1
		if c == 0 and prime(N) == True:
			return 1
		return 0


import math

class Solution:

	def fullPrime(self, N):

		def isPrime(N):
			f = 0
			if N == 1 or N == 0:
				return 0
			for i in range(2, int(math.sqrt(N) + 1)):
				if N % i == 0:
					return 0
			else:
				return 1
		if isPrime(N):
			while N > 0:
				r = N % 10
				if isPrime(r) == 0:
					return 0
					break
				N = N // 10
			else:
				return 1
		else:
			return 0


import math as m

class Solution:

	def fullPrime(self, n):
		b = pow(n, 0.5)
		b = int(b)
		c = 0
		for i in range(1, b + 1):
			if n % i == 0:
				c += 1
		if c != 1:
			return 0
		else:
			n = str(n)
			n = list(n)
			n = [eval(i) for i in n]
			r = 0
			for i in n:
				c = 0
				for j in range(1, i + 1):
					if i % j == 0:
						c += 1
				if c == 2:
					r += 1
				c = 0
			if r == len(n):
				return 1
			return 0


import math

class Solution:

	def fullPrime(self, k):
		s = str(k)
		v = 0
		for i in s:
			n = int(i)
			c = 0
			for i in range(2, int(math.sqrt(n) + 1)):
				if n % i == 0:
					c += 1
			if c != 0 or n == 1 or n == 0:
				return '0'
		c = 0
		for i in range(2, int(math.sqrt(k) + 1)):
			if k % i == 0:
				c += 1
		if c != 0 or n == 1:
			return '0'
		else:
			return '1'


import math

class Solution:

	def fullPrime(self, N):
		c = 0
		for i in range(2, int(math.sqrt(N)) + 1):
			if N % i == 0:
				c += 1
				break
		if c == 0:
			t = 0
			while N != 0:
				r = N % 10
				N = N // 10
				if r <= 1:
					t = 1
				for i in range(2, int(math.sqrt(r)) + 1):
					if r % i == 0:
						t += 1
		if c > 0:
			return '0'
		elif t == 0:
			return '1'
		else:
			return '0'


class Solution:

	def fullPrime(self, N):

		def primme(n):
			if n < 2:
				return False
			for i in range(2, int(n ** 0.5) + 1):
				if n % i == 0:
					return False
			return True
		if primme(N):
			while N > 0:
				r = N % 10
				if primme(r) is False:
					return '0'
				N = N // 10
			return '1'
		else:
			return '0'


import math

class Solution:

	def fullPrime(self, N):
		l = {2, 5, 7, 3}
		f = 0
		if N == 1:
			f = 1
		for i in range(2, int(math.sqrt(N)) + 1):
			if N % i == 0:
				f = 1
				break
		g = 0
		while N > 0:
			r = N % 10
			if r not in l:
				g = 1
				break
			N = N // 10
		if f == 0 and g == 0:
			return 1
		else:
			return 0


import math

def isprime(c):
	if c < 2:
		return False
	for i in range(2, int(math.sqrt(c)) + 1):
		if c % i == 0:
			return False
	return True

class Solution:

	def fullPrime(self, N):
		a = N
		d = 0
		s = str(N)
		n = list(map(int, s))
		if isprime(a):
			for i in n:
				if isprime(i):
					d += 1
		if d == len(n):
			return 1
		else:
			return 0


import math

class Solution:

	def fullPrime(self, N):

		def isprime(N):
			if N == 1 or N == 0:
				return 0
			else:
				for i in range(2, int(math.sqrt(N)) + 1):
					if N % i == 0:
						return 0
				return 1
		k = N
		s = 0
		c = 0
		while k:
			k //= 10
			s += 1
		if isprime(N) == 0:
			return 0
		else:
			while N:
				r = N % 10
				if isprime(r) == 1:
					c += 1
				N //= 10
			if c == s:
				return 1
			else:
				return 0


import math as m

class Solution:

	def fullPrime(self, N):

		def prime(n):
			if n == 0 or n == 1:
				return False
			for i in range(2, round(m.sqrt(n)) + 1):
				if n % i == 0:
					return False
			return True
		if prime(N) == True:
			while N:
				if prime(N % 10) == False:
					return 0
				N = N // 10
			return 1
		else:
			return 0


import math

class Solution:

	def fullPrime(self, N):
		q = N
		cnt = 0
		cnt1 = 0
		while N:
			cnt1 += 1
			d = N % 10
			if is_prime(d):
				cnt += 1
			N = N // 10
		if cnt == cnt1 and is_prime(q):
			return 1
		else:
			return 0

def is_prime(num):
	if num == 1 or num == 0:
		return False
	sq = int(math.sqrt(num))
	for i in range(2, sq + 1):
		if num % i == 0:
			return False
	else:
		return True


class Solution:

	def fullPrime(self, N):

		def prime(x):
			if x == 0 or x == 1:
				return False
			s = int(x ** 0.5)
			for i in range(2, s + 1):
				if x % i == 0:
					return False
			return True
		if prime(N):
			for i in str(N):
				if not prime(int(i)):
					return 0
			else:
				return 1
		else:
			return 0


def isPrime(n):
	if n <= 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

class Solution:

	def fullPrime(self, N):
		flag = 0
		if isPrime(N):
			N = str(N)
			flag = 1
			for i in N:
				if not isPrime(int(i)):
					return 0
		return flag


from math import sqrt
from bisect import bisect
primes = [2, 3]

class Solution:

	def fullPrime(self, N):
		while int(sqrt(N)) >= primes[-1]:
			i = primes[-1]
			flag = False
			while not flag:
				i += 2
				flag = True
				for item in primes:
					if i % item == 0:
						flag = False
						break
				if flag:
					primes.append(i)
		for item in str(N):
			if item not in '2357':
				return 0
		i = bisect(primes, sqrt(N))
		for item in primes[:i]:
			if N % item == 0:
				return 0
		return 1


class Solution:

	def fullPrime(self, N):
		prime = [2, 3, 5, 7]
		temp = N
		for j in range(len(str(N))):
			rem = temp % 10
			if rem not in prime:
				return 0
			temp = temp // 10
		for i in range(2, int(N / 2) + 1):
			if N % i == 0:
				return 0
		return 1


class Solution:

	def fullPrime(self, N):
		outflg = 0

		def check(N):
			if N == 2 or N == 3:
				return 1
			for i in range(2, int(N ** 0.5 + 1)):
				if N % i == 0:
					return 0
			return 1
		if check(N):
			while N > 0:
				remainder = N % 10
				if remainder == 0 or remainder == 1:
					outflg = 1
					break
				N = N // 10
				res = check(remainder)
				if res != 1:
					outflg = 1
					break
			if outflg == 1:
				return 0
			else:
				return 1
		else:
			return 0


from math import sqrt

class Solution:

	def fullPrime(self, N):
		if N == 1 or N == 0:
			return 0
		i = 2
		while i <= sqrt(N):
			if N % i == 0:
				return 0
			i += 1
		if len(str(N)) > 1:
			for ele in str(N):
				if not self.fullPrime(int(ele)):
					return 0
		return 1


import math

class Solution:

	def fullPrime(self, N):

		def Prime(N):
			if N == 1 or N == 0:
				return False
			for i in range(2, math.floor(math.sqrt(N)) + 1):
				if N % i == 0:
					return False
			return True
		if Prime(N):
			while N > 0:
				rem = N % 10
				if Prime(rem):
					pass
				else:
					return 0
				N = N // 10
			return 1
		else:
			return 0


class Solution:

	def fullPrime(self, N):
		if N < 2:
			return 0
		for i in range(2, int(N ** 0.5) + 1):
			if N % i == 0:
				return 0
		for d in str(N):
			if int(d) < 2:
				return 0
			for i in range(2, int(int(d) ** 0.5) + 1):
				if int(d) % i == 0:
					return 0
		return 1